Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Window Message

Status
Not open for further replies.

DeCoDeR

Programmer
Joined
Jun 4, 2002
Messages
37
Location
US
Hi,
I am using MFC dialog ( default one coming with if you choose MFC.exe as project type ). I can add mfc message handlers like WM_CHAR etc to my application. How can i add a custom message handler ?

Read between the lines
 
Something like this could do it

#define WM_CUSTOM_MSG WM_USER+35

...

PostMessage(WM_CUSTOM_MSG);


and in PretranslateMessage


switch (pMsg->message)
{
case WM_CUSTOM_MSG:
{
MakeANewSourceSelection();
return TRUE;
}
}

Matt
 
An even more elegant solution is instead of overloading PreTranslateMessage(), add message map entries for your message by hand.

In between the BEGIN_MESSAGE_MAP() and END_MESSAGE_MAP() macros in the .cpp file, put the following entry:

ON_MESSAGE(MY_MESSAGE, memberFxn)

The prototype for memberFxn is

afx_msg LRESULT memberFxn(WPARAM, LPARAM);
 
thanx very much
both works
Regards
Read between the lines
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top