Sending User defined messages 
Author Message
 Sending User defined messages

Hi, I have a bunch of objects which are organized and displayed using the
Document/View architecture.  I would like to send a message fromt the
object to the view.  To do this I have defined my own message:

#define WM_MYMESSAGE (WM_USER+1)

Object code:
        ...
        PostMessage(NULL,WM_MYMESSAGE,wParam,lParam);
        ...

Then in the view I trap for the WM_MYMESSAGE in the message map

        ON_MESSAGE(WM_MYMESSAGE, OnMyMessage(WPARAM,LPARAM);

OnMyMessage never gets called.  Any ideas?

Thanks in advance!




Sat, 06 Nov 1999 03:00:00 GMT  
 Sending User defined messages

Try AfxGetMainWnd()->PostMessage(WM_MYMESSAGE,wParam,lParam);

That gives it the proper destination to get into the message maps, even
though it may be destined for a view class eventually.  And the beauty
of AfxGetMainWnd() is that it's global and will work from anywhere --
even non-window objects.

Quote:

> Hi, I have a bunch of objects which are organized and displayed using the
> Document/View architecture.  I would like to send a message fromt the
> object to the view.  To do this I have defined my own message:

> #define WM_MYMESSAGE (WM_USER+1)

> Object code:
>         ...
>         PostMessage(NULL,WM_MYMESSAGE,wParam,lParam);
>         ...

> Then in the view I trap for the WM_MYMESSAGE in the message map

>         ON_MESSAGE(WM_MYMESSAGE, OnMyMessage(WPARAM,LPARAM);

> OnMyMessage never gets called.  Any ideas?

> Thanks in advance!





Sat, 06 Nov 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. How to send User defined Message between CMDIChildWnd?

2. Send user defined message from modal dialog to View

3. Sending a user defined message

4. sending user defined windows messages to a CCmdTarget derived class

5. example of user define message sending and handling

6. Windows.Forms.Message - processing a user defined Windows-message - 2nd try

7. User defined messages and the message loop

8. handling user-defined messages (WM_USER) with message maps

9. Can't Send User Defined Data Through a Connection Point

10. User define message is lost in the thread!!!

11. user defined, attach to message

12. user defined messages

 

 
Powered by phpBB® Forum Software