ON_MESSAGE和ON_REGISTERED_MESSAGE
on_message用于处理一切消息,但是on_registered_message只用处理在系统已经注册过的消息。
The RegisterWindowMessage function is used to define a new window message that is guaranteed to be unique throughout the system. The macro ON_REGISTERED_MESSAGE is used to handle these messages. This macro accepts a name of a UINT NEAR variable that contains the registered windows message ID.
class CMyWnd : public CMyParentWndClass { public: CMyWnd(); //{{AFX_MSG(CMyWnd) afx_msg LRESULT OnFind(WPARAM wParam, LPARAM lParam); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; static UINT NEAR WM_FIND = RegisterWindowMessage("COMMDLG_FIND"); BEGIN_MESSAGE_MAP(CMyWnd, CMyParentWndClass) //{{AFX_MSG_MAP(CMyWnd) ON_REGISTERED_MESSAGE(WM_FIND, OnFind) //}}AFX_MSG_MAP END_MESSAGE_MAP()