how to send message to CCmdTarget
-
To send a message to a CWnd derived object is easy, I use SendMessage() method. Could anyone help me understand how to send message to a CCmdTarget derived object such as CDocument which owns a message table (BEGIN_MESSAGE_MAP/END_MESSAGE_MAP) ? Perhaps I'm just going down the difficult path. Namely, I'm trying to send a "new-document" menu message to the SDI document to force cleanup and get the "option to save modified" feature. For some reason if I call OnNewDocument() method directly the framework ignors the fact that the current document is "modified". I though sending the menu message would fool the framework to do its job. Thanks bunches Alex
-
To send a message to a CWnd derived object is easy, I use SendMessage() method. Could anyone help me understand how to send message to a CCmdTarget derived object such as CDocument which owns a message table (BEGIN_MESSAGE_MAP/END_MESSAGE_MAP) ? Perhaps I'm just going down the difficult path. Namely, I'm trying to send a "new-document" menu message to the SDI document to force cleanup and get the "option to save modified" feature. For some reason if I call OnNewDocument() method directly the framework ignors the fact that the current document is "modified". I though sending the menu message would fool the framework to do its job. Thanks bunches Alex
You could just call the menu handler directly -
OnFileNew()
. The other way (as you suggest) is to send aWM_COMMAND
message with theID_FILE_NEW
command ID to your main window (not to the document directly).Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"