MFC中消息映射机制(BEGIN_MESSAGE_MAP和END_MESSAGE_MAP)
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;
}
常记溪亭日暮,沉醉不知归路。兴尽晚回舟,误入藕花深处。争渡,争渡,惊起一滩鸥鹭。
昨夜雨疏风骤,浓睡不消残酒。试问卷帘人,却道海棠依旧。知否?知否?应是绿肥红瘦。