MFC custom message

1. header file

#define WM_MYMSG WM_USER + 1 // WM_USER ~ 0x7fff i.e. in the range of 0x0400 ~ 0x7fff

afx_msg LRESULT OnMyMsg(WPARAM wParam, LPARAM lParam);

2. cpp file

BEGIN_MESSAGE_MAP(CMyWnd, CMyParentWndClass)
  ON_MESSAGE(WM_MYMSG, OnMyMsg)
END_MESSAGE_MAP()

afx_msg LRESULT CMyWnd::OnMyMsg(WPARAM wParam, LPARAM lParam)
{
....
}

3. use elsewhere

CMyWnd* pWnd = ...;
pWnd->SendMessage(WM_MYMSG);

Guess you like

Origin www.cnblogs.com/htj10/p/11931165.html