创建了一个简单的的对话框应用, 给对话框上的OK按钮添加了处理函数
void CVirusProcessDlg::OnOK()
{
// TODO: Add extra validation here
CDialog::OnOK();
}
后, 在下面这个地方
BOOL CVirusProcessApp::InitInstance()
{
AfxEnableControlContainer(); // Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif CVirusProcessDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
//**********************************************************************
//我在这里添加了一个MessageBox("111123455");, 结果没有弹出来, 单步调试的时候
//点击对话框的OK的时候的的确确是运行到这里了的.但是就是没有弹出来.
//**********************************************************************
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
} // Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
MessageBox(NULL, "YEAH", "YEAH", MB_OK|MB_YESNO|MB_ICONSTOP);
return FALSE;
}谁帮忙解释一下.....
void CVirusProcessDlg::OnOK()
{
// TODO: Add extra validation here
CDialog::OnOK();
}
后, 在下面这个地方
BOOL CVirusProcessApp::InitInstance()
{
AfxEnableControlContainer(); // Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif CVirusProcessDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
//**********************************************************************
//我在这里添加了一个MessageBox("111123455");, 结果没有弹出来, 单步调试的时候
//点击对话框的OK的时候的的确确是运行到这里了的.但是就是没有弹出来.
//**********************************************************************
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
} // Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
MessageBox(NULL, "YEAH", "YEAH", MB_OK|MB_YESNO|MB_ICONSTOP);
return FALSE;
}谁帮忙解释一下.....
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
//**********************************************************************
//我在这里添加了一个MessageBox("111123455");, 结果没有弹出来, 单步调试的时候
//点击对话框的OK的时候的的确确是运行到这里了的.但是就是没有弹出来.
//**********************************************************************
}
你这里调用dlg.DoModal()之后,要在你关闭窗体之后才会才会走到MessageBox这里吧?
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
MSG msg;
if (::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
::TranslateMessage(&msg);
::DispatchMessage(&msg);
}
::MessageBox(NULL, _T("OK is Clicked"), _T("Message"), MB_OK);
}
1. 消息循环是在什么时候创建的, 又是在什么时候销毁的?
2. 添加了peekmessage这几行代码后, 这个BOX怎么就可以出来了呢, 是不是MessageBox给主线程发了一个消息,让他显示窗口,
那么这个这一块的消息处理在哪里呢?