How to activate OnFileNew()?
-
I work on a single document app. Now I have the problem that messagehandling doesn't work right. I want to activate the creation of a new document from another point as the main menu and toolbar. For that purpose I included
ON_COMMAND(ID_FILE_NEW, OnFileNew)
in a view class and tried to start the OnFileNew() function by sending a message to the view class:pvw->SendMessage(ID_FILE_NEW)
It doesn't work! When debugging the whole matter I saw that OnFileNew() wasn't activated (and processed). Even if it does, I have to do all by myself (setting default name for empty document and so on). How can I activate the applications OnFileNew Funktion? Why doesn't the message sending work? I hope someone helps me with that (basic MFC) matter. -
I work on a single document app. Now I have the problem that messagehandling doesn't work right. I want to activate the creation of a new document from another point as the main menu and toolbar. For that purpose I included
ON_COMMAND(ID_FILE_NEW, OnFileNew)
in a view class and tried to start the OnFileNew() function by sending a message to the view class:pvw->SendMessage(ID_FILE_NEW)
It doesn't work! When debugging the whole matter I saw that OnFileNew() wasn't activated (and processed). Even if it does, I have to do all by myself (setting default name for empty document and so on). How can I activate the applications OnFileNew Funktion? Why doesn't the message sending work? I hope someone helps me with that (basic MFC) matter.well friend, i will not go in detail of message handling, but i will concentrate on your basic problem of Starting a new document whenever you click File->New. When you use App Wizard and create a single document app, it automatically does it for you. And if you wnat to do something else on file->new (like automatically saving the previous file without prompting etc anything) then you and Message handler using the Class Wizard to your Mainframe or any view class. Hope that make things clearer, if not make post.:rose: hey did you forget to rate? Plz rate my reply.
-
I work on a single document app. Now I have the problem that messagehandling doesn't work right. I want to activate the creation of a new document from another point as the main menu and toolbar. For that purpose I included
ON_COMMAND(ID_FILE_NEW, OnFileNew)
in a view class and tried to start the OnFileNew() function by sending a message to the view class:pvw->SendMessage(ID_FILE_NEW)
It doesn't work! When debugging the whole matter I saw that OnFileNew() wasn't activated (and processed). Even if it does, I have to do all by myself (setting default name for empty document and so on). How can I activate the applications OnFileNew Funktion? Why doesn't the message sending work? I hope someone helps me with that (basic MFC) matter.You have to send or rather post a WM_COMMAND message with ID_FILE_NEW as parameter to your view class. Hope this helps -- Roger
-
well friend, i will not go in detail of message handling, but i will concentrate on your basic problem of Starting a new document whenever you click File->New. When you use App Wizard and create a single document app, it automatically does it for you. And if you wnat to do something else on file->new (like automatically saving the previous file without prompting etc anything) then you and Message handler using the Class Wizard to your Mainframe or any view class. Hope that make things clearer, if not make post.:rose: hey did you forget to rate? Plz rate my reply.
I did not make me clear enough. I used the App Wizard and clicking the New Document button or selecting it in main menu works. I want to start it from another point too. For example a context menu or from another button. If there is a button in another toolbar that launches a funktion that requires a new document, I have to call the OnFileNew Funktion. But it doesn't work at the moment. How can I create a new document from within own classes or functions?
-
You have to send or rather post a WM_COMMAND message with ID_FILE_NEW as parameter to your view class. Hope this helps -- Roger