mfc >> Message Handler

by coder » Fri, 28 Jan 2005 14:19:34 GMT

Hi guys,
How is to possible to define a windows message handler function
for a runtime window message?

lets say at runtime in reponse to a pressing a button,
I do a RegisterWindow(..) and then I had like to do the processing in
reponse to the message returned by the above call.

How can I handle the processoing of such a message id at runtime?

Thanks
Vipin




mfc >> Message Handler

by Frank Hickman [MVP] » Fri, 28 Jan 2005 14:41:26 GMT






You need to process a message id created with RegisterWindowMessage using an
if statement because you cannot use variables in a case statement. Since
you posted this in MFC I am going to assume you want to know where to handle
it...you can either override the WindowProc or PreTranslateMessage, I guess
it really depends on what your doing with it.

--
============
Frank Hickman
Microsoft MVP
NobleSoft, Inc.
============
Replace the _nosp@m_ with @ to reply.






mfc >> Message Handler

by Scott McPhillips [MVP] » Fri, 28 Jan 2005 20:36:13 GMT





In the MFC message map you can add a ON_REGISTERED_MESSAGE line to map a
message created at run time by RegisterWindowMessage. You have to type
this in by hand - not available from wizard.

--
Scott McPhillips [VC++ MVP]



Message Handler

by coder » Sat, 29 Jan 2005 01:46:01 GMT

Thanks this is the answer I was after and not Frank's.








Message Handler

by coder » Sat, 29 Jan 2005 03:27:26 GMT

Any clue how to do this in ATL with no MFC?
Thanks








Message Handler

by coder » Sat, 29 Jan 2005 04:22:51 GMT

ignore this.










Similar Threads

1. Pass Message to Base Class Message Handler

2. Add message handler?

3. Problem with adding message handlers using wizard

4. Default window proc not being called from message handler

I have a CWindowImpl<> derived window which superclasses the button 
control. I handle the WM_PAINT message in a message handler. In a 
certain logic path of the message handler I want the default window proc 
   to handle the WM_PAINT message, so I set the bHandled parameter to 
FALSE and return a non-zero. The default window proc does not appear to 
be handling the message since the button was created with a window name, 
which for a button becomes the text to display in the window, and the 
text does not appear. If I do not handle the WM_PAINT message, the text 
appears.

Why does setting bHandled to FALSE not induce the default window proc to 
handle the message ?

5. CoCreateInstance and windows hook message handlers

6. Adding message handlers in VC++7.1 IDE

In VC++ 6 it was easy: I'd right click the class, choose 'Add Message
Handler' (or whatever it was called) and select one from the list.

In VC++ 7.1 it seems to be impossible: Right click the class, choose
properties, select the Messages list, find the appropriate message and click
in the box, click the down arrow, click '<Add> OnMessageHandler', get
"Invalid Property Value" error: "The SetValue operation on the component
failed with the error code 0x80070005".

As far as I'm concerned, this is far more effort for zero reward. Is there a
better way?

--- Al.


7. Unable to add message handlers or variables - Microsoft Visual C++/VC++

8. Add Message Handler to CWinApp or CMainFrame

Hi,
I'm not sure about getting which class for the "OnIdle" Event? (CWinApp or 
CMainFrame?)Or both have :)
And In VC6, there used to be the classwizard. Now, I wanted to add an event 
handler, how do I get it? Thanks
J