LRESULT CTestDlg::OnMyMsg(WPARAM wParam, LPARAM lParam)
{...}
BEGIN_MESSAGE_MAP(CTestDlg, CDialog)
...
ON_MESSAGE(WM_MY_MSG, &CTestDlg::OnMyMsg)
END_MESSAGE_MAP()
void CTestApp::OnMyThrdMsg(WPARAM wParam, LPARAM lParam)
{...}
BEGIN_MESSAGE_MAP(CTestApp, CWinAppEx)
...
ON_THREAD_MESSAGE(WM_MY_THRD_MSG, &CTestApp::OnMyThrdMsg)
END_MESSAGE_MAP()
那怎样在当前线程中触发消息呢?有以下两种方法:
::PostMessage(NULL, WM_MY_THRD_MSG, 0, 0);
::PostThreadMessage(::GetCurrentThreadId(), WM_MY_THRD_MSG, 0, 0);
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。