我在WinApp中声明了一个事件句柄test_evt,并在构造函数中创建它
test_evt = ::CreateEvent(NULL,TRUE,FALSE,"evt");
if (test_evt == NULL)
{
AfxMessageBox("create event failed");
}然后自WinApp的Run里面等待test_evt被激发
int CMsgwaitApp::Run()
{
// TODO: Add your specialized code here and/or call the base class
if (WAIT_OBJECT_0 == ::MsgWaitForMultipleObjectsEx(1,&test_evt,INFINITE,QS_ALLINPUT,MWMO_INPUTAVAILABLE
))
{
AfxMessageBox("ok");
} return CWinApp::Run();
}
然后重写对话框的OK按钮处理函数
void CMsgwaitDlg::OnOK()
{
// TODO: Add extra validation here
HANDLE h = ::OpenEvent(EVENT_ALL_ACCESS,FALSE,"evt");
::SetEvent(h);
// CDialog::OnOK();
}
为什么按下OK,却没有消息框弹出?
test_evt = ::CreateEvent(NULL,TRUE,FALSE,"evt");
if (test_evt == NULL)
{
AfxMessageBox("create event failed");
}然后自WinApp的Run里面等待test_evt被激发
int CMsgwaitApp::Run()
{
// TODO: Add your specialized code here and/or call the base class
if (WAIT_OBJECT_0 == ::MsgWaitForMultipleObjectsEx(1,&test_evt,INFINITE,QS_ALLINPUT,MWMO_INPUTAVAILABLE
))
{
AfxMessageBox("ok");
} return CWinApp::Run();
}
然后重写对话框的OK按钮处理函数
void CMsgwaitDlg::OnOK()
{
// TODO: Add extra validation here
HANDLE h = ::OpenEvent(EVENT_ALL_ACCESS,FALSE,"evt");
::SetEvent(h);
// CDialog::OnOK();
}
为什么按下OK,却没有消息框弹出?
int CMsgwaitApp::Run()
{
// TODO: Add your specialized code here and/or call the base class
AfxMessageBox("ok"); return CWinApp::Run();
}
发现根本不会跳出消息框