DECLARE_MESSAGE_MAP() BEGIN_MESSAGE_MAP(CtestDialogDlg, CDialogEx) ON_WM_PAINT() //OnPaint() ON_WM_QUERYDRAGICON() // ON_WM_SYSCOMMAND() //OnSysCommand() ON_WM_SIZE() //OnSize() ON_MESSAGE(WM_USER_MSG, &CtestDialogDlg::OnUserMsg) //自定义消息 ... END_MESSAGE_MAP()
自定义消息的步骤:
1. 头文件中
#define WM_USER_MSG (WM_USER + 1)
afx_msg LRESULT OnUserMsg(WPARAM wParam, LPARAM lParam);
2. cpp文件中
BEGIN_MESSAGE_MAP(CtestDialogDlg, CDialogEx)
ON_MESSAGE(WM_USER_MSG, &CtestDialogDlg::OnUserMsg) //自定义消息
END_MESSAGE_MAP()
afx_msg LRESULT CtestDialogDlg::OnUserMsg(WPARAM wParam, LPARAM lParam)
{
....
return 0;
}