handling user-defined messages (WM_USER) with message maps 
Author Message
 handling user-defined messages (WM_USER) with message maps

Can I just add a messagemap entry..
ON_MESSAGE( WM_USER, OnWmUser )

define my message map function in header file
afx_msg void OnWmUser();

and implement it in the cpp file:
void OnWmUser( )
{
    ...do something spiffy

Quote:
}

???

It would seem to easy to be true :-)



Tue, 26 Mar 2002 03:00:00 GMT  
 handling user-defined messages (WM_USER) with message maps

Quote:

> Can I just add a messagemap entry..
> ON_MESSAGE( WM_USER, OnWmUser )

> define my message map function in header file
> afx_msg void OnWmUser();

> and implement it in the cpp file:
> void OnWmUser( )
> {
>     ...do something spiffy
> }
> ???

> It would seem to easy to be true :-)

Well, it's true that that's about how easy it is, but your implementation
outline has several errors.  Check out this to get the details right:
  http://www.mvps.org/vcfaq/mfc/index.htm

--
Scott McPhillips [VC++ MVP]



Tue, 26 Mar 2002 03:00:00 GMT  
 handling user-defined messages (WM_USER) with message maps

Quote:

>Can I just add a messagemap entry..
>ON_MESSAGE( WM_USER, OnWmUser )

Don't use WM_USER, the system itself uses messages in the low WM_USER
range for dialogs (I know, dumb isn't it). Use WM_APP. Better still
use RegisterWindowMessage and ON_REGISTERED_MESSAGE.

Quote:
>define my message map function in header file
>afx_msg void OnWmUser();

You need to follow the correct format for a message handler, with an
LRESULT, a WPARAM and an LPARAM. This is documented in the help on
user defined handlers.

--
Bob Moore [MVP]
http://www.mooremvp.freeserve.co.uk
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Due to an unreasonable amount of queries, I no
longer answer unsolicited email questions. Sorry,
no exceptions, and yes, this DOES mean you.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Wed, 27 Mar 2002 03:00:00 GMT  
 handling user-defined messages (WM_USER) with message maps
Check out my essay on user-defined messages on
http://www3.pgh.net/~newcomer/mvp_tips.htm
                        joe



Quote:
>Can I just add a messagemap entry..
>ON_MESSAGE( WM_USER, OnWmUser )

>define my message map function in header file
>afx_msg void OnWmUser();

>and implement it in the cpp file:
>void OnWmUser( )
>{
>    ...do something spiffy
>}
>???

>It would seem to easy to be true :-)

Joseph M. Newcomer

Web: www3.pgh.net/~newcomer
MVP Tips: www3.pgh.net/~newcomer/mvp_tips.htm
Author of "Win32 Programming" (with Brent Rector, Addison-Wesley, 1997)
Author of "Developing Windows NT Device Drivers" (with Ed Dekker, AWL, 1999)


Thu, 28 Mar 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. User Defined Message Maps

2. Adding user messages to a message map

3. Handling User-Defined Messages

4. example of user define message sending and handling

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

6. User defined messages and the message loop

7. MFC Map User Message

8. Message Map handling problem

9. handle mapped messages in two windows

10. Thread handles and the message map

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

12. user defined, attach to message

 

 
Powered by phpBB® Forum Software