Programming Tips - MFC: What messages are sent to my MFC control?

Date: 2009may31 Framework: MFC Language: C/C++ Q. MFC: What messages are sent to my MFC control? A. To see what messages your MFC is getting override the OnWndMsg() function. In your .h file add this:
class CMyButton : public CButton { ... // ADD THIS virtual BOOL OnWndMsg( UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult ); ... };
In your .cpp file add this:
CMyButton::BOOL OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult) { printf("CMyButton got windows messsage 0x%0x\n", message); return FALSE; // Say you have not processed the message }