1、新建一个SHOW名称的对话框文件
2、在SHOWDlg.h中添加代码
cpp
#define WM_Display (WM_USER+100)
afx_msg LRESULT OnDisplay(WPARAM wParam, LPARAM lParam);
3、在SHOWDlg.cpp中添加代码
cpp
BEGIN_MESSAGE_MAP(CSHOWDlg, CDialog)
...
ON_MESSAGE(WM_Display, OnDisplay)
END_MESSAGE_MAP()
BOOL CSHOWDlg::OnInitDialog()
{
CDialog::OnInitDialog();
::PostMessage(GetSafeHwnd(),WM_Display,0,0);
...
return TRUE; // return TRUE unless you set the focus to a control
}
LRESULT CSHOWDlg::OnDisplay(WPARAM wParam, LPARAM lParam)
{
//MessageBox("recv msg success");
//添加自己的消息处理
MessageBox("WM_USER_message");
return 0;
}
3、运行程序