这个神奇的MessageBox()我是写在这个位置的,MFC工程的APP类的InitInstance()里—— CtestMFCDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: 在此放置处理何时用
// “确定”来关闭对话框的代码
}
else if (nResponse == IDCANCEL)
{
// TODO: 在此放置处理何时用
// “取消”来关闭对话框的代码
}
int iMBRet = MessageBox(NULL, _T("123"), _T("abc"), MB_ICONWARNING);
int iLastErr = GetLastError();
大家可以试试,好好玩的,这里的MessageBox()会秒过。iMBRet == 1,iLastErr == 0。
请教大家原因,谢谢!
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: 在此放置处理何时用
// “确定”来关闭对话框的代码
}
else if (nResponse == IDCANCEL)
{
// TODO: 在此放置处理何时用
// “取消”来关闭对话框的代码
}
int iMBRet = MessageBox(NULL, _T("123"), _T("abc"), MB_ICONWARNING);
int iLastErr = GetLastError();
大家可以试试,好好玩的,这里的MessageBox()会秒过。iMBRet == 1,iLastErr == 0。
请教大家原因,谢谢!
解决方案 »
- 请帮小弟看个简单代码---线程新手问题
- 在dialogbox中同时贴背景与使用animatewindow时产生问题
- 我第一次使用CList就错了.
- 请问vc6中到底如何直接打开.rc文件啊?每次双击之后都是直接进入图形界面,我想直接看.rc代码怎么看啊???
- 获取外网ip??请教!急!!
- 软件测试方案怎么写
- 如何设置CListCtrl控件的背景和文本色?
- 哪里有像QQ那样的发消息,传文件的程序代码阿??谢谢大侠(内空)
- openssl 中进行AES加密 密钥如何获取
- 解答初学者:一个简单问题。谢谢!!
- 整了半天,郁闷完了。求助有关BUTTON下拉菜单的问题。
- 在Directx10中怎么用DirectShow啊?有经验的帮帮忙啊!
// application, rather than start the application's message pump.
return FALSE;
// for 回复内容太短了!
{
// TODO: 在此放置处理何时用
; // “确定”来关闭对话框的代码
}
else if (nResponse == IDCANCEL)
{
// TODO: 在此放置处理何时用
;// “取消”来关闭对话框的代码
}
DoModal()函数返回之后,m_pMainWnd为NULL了,MSDN上这样描述:
If this data member is NULL, the main window for the application's CWinApp object will be used to determine when to terminate the thread. m_pMainWnd is a public variable of type CWnd*. 主线程结束,进程即将退出了
当调用MessageBox 时,此时应用程序已经在“终止的”
所以应用程序会强制终止MessageBox 框
具体原因,可以看看msdn对m_pMainWnd 成员的解释:
Use this data member to store a pointer to your thread’s main window object. The
Microsoft Foundation Class Library will automatically terminate your thread when the
window referred to by m_pMainWnd is closed. If this thread is the primary thread for an application, the application will also be terminated. If this data member is
NULL, the main window for the application’s CWinApp object will be used to determine
when to terminate the thread. m_pMainWnd is a public variable of type CWnd*.