1. 头文件
#define WM_MYMSG WM_USER+1 // 范围在 WM_USER ~ 0x7fff 即 0x0400 ~ 0x7fff
afx_msg LRESULT OnMyMsg(WPARAM wParam, LPARAM lParam);
2. cpp文件中
BEGIN_MESSAGE_MAP(CMyWnd, CMyParentWndClass)
ON_MESSAGE(WM_MYMSG, OnMyMsg)
END_MESSAGE_MAP()
afx_msg LRESULT CMyWnd::OnMyMsg(WPARAM wParam, LPARAM lParam)
{
....
}
3. 在其他地方使用
CMyWnd* pWnd = ...;
pWnd->SendMessage(WM_MYMSG);