BOOL PostMessage(
HWND hWnd, // handle to destination window
UINT Msg, // message
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
HWND hWnd, // handle to destination window
UINT Msg, // message
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
[in] Handle to the window whose window procedure is to receive the message. The following values have special meanings. Value Meaning
HWND_BROADCAST The message is posted to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and pop-up windows. The message is not posted to child windows.
NULL The function behaves like a call to PostThreadMessage with the dwThreadId parameter set to the identifier of the current thread.
可以把#define xxx_xxx WM_USER+112放在AFXSTD.H里
#define xxx_xxx WM_USER+112
class CMyDialog
{
.......
afx_msg void ReceiveMessage(WPARAM wParam,LPARAM);
......
}//MyDialog.cpp
...
ON_MESSAGE(xxx_xxx,ReceiveMessage)...
void CMyDialog::ReceiveMessage(WPARAM wParam,LPARAM)
{
...
}//下面在某个函数中
//pMyDialog 指向你的某个CMyDilog 对象
::PostMessage(pMyDialog->GetSafeHWnd(),0,0);
......
不可以用ClassWirard 的,只能用手工
AfxGetMainWnd()->PostMessage(xxx_xxx,0,0);或是取得当前类的HWND,
::PostMessage(this->m_hWnd,xxx_xxx,0,0);
//MyView.h
……
CMyDialog MyDialog;
……
//MyView.cpp
……
……MyDialog.DoModal()……
…… 我想实现的是:对话框的某个按钮按下,传一个消息给视图,以期让视图实现某些操作。