Programming Tips - MFC: Send a custom message to myself using MFC ?

Date: 2014jul22 Framework: MFC Language: C/C++ OS: Windows Q. MFC: Send a custom message to myself using MFC ? A. In your .h file:
// Define your message as some offset from WM_APP enum { WM_MYMESSSAGE = WM_APP + 1 }; // With the other afx_msg's: afx_msg LRESULT OnMyMessage(WPARAM wParam, LPARAM lParam);
In your .cpp file:
// Add it so the message map using ON_MESSAGE() BEGIN_MESSAGE_MAP(CMyDialog, CDialog) ON_MESSAGE(WM_MYMESSAGE, OnMyMessage) END_MESSAGE_MAP() // Finally your function LRESULT CMyDialog::OnMyMessage(WPARAM wParam, LPARAM lParam) { // Do whatever you want now return 0; } // To send the message use: PostMessage(WM_MYMESSAGE);