Sign in to follow this  
johnnyBravo

MFC, how to get to message handler? eg WPARAM wParam, LPARAM lParam

Recommended Posts

Hi, I'm using MFC, I've got some code that would usually in a win32 application, go in the MsgProc(WndProc) whatever you call it, the message handler i think its called. eg
Quote:
LRESULT WINAPI MsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch( msg ) { } return DefWindowProc( hWnd, msg, wParam, lParam ); }
Anyway I need to use WPARAM wParam and LPARAM lParam from inside MFC. How would I get around to getting these variables? Thanks

Share this post


Link to post
Share on other sites
if you created the MFC app using a wizard then look for something called a message map, every message that is to be handled will be in there with a custom function to call on receiving that message (no more parsing the params yourself, it'll already be in a nice form with most messages).

the message map looks like this


BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
ON_WM_CREATE()
END_MESSAGE_MAP()


to handle another message you need to put the code in there and they will take a function pointer of the function to call on receiving that message. Most of the messages are the same as Win32 except with the 'ON_' infront of them.

Hope that helped

Share this post


Link to post
Share on other sites
if its an mfc class derrived from CWnd then theres a virtual WndProc func in there. add it via the class wizard (vc6) or its in one of the tabs in the propery page (vc.net)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this