首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

关于DoModal()解决思路

2012-05-13 
关于DoModal()C/C++ codeint nResponse dlg.DoModal()if (nResponse IDOK){AfxMessageBox(ok)}el

关于DoModal()

C/C++ code
int nResponse = dlg.DoModal();if (nResponse == IDOK){    AfxMessageBox("ok");}else if (nResponse == IDCANCEL){    AfxMessageBox("cancel");}

为什么对话框关闭后不会弹出消息框?


[解决办法]
正常现象--
这里的对话框是线程主窗口,CWnd::OnNcDestroyWindow检测到线程主窗口关闭会PostQuitMeaasge,而在PostQuitMeaasge后的MessageBox是不会显示的,它会立即关闭(所以这里只能听见MessageBox发出的声音)
[解决办法]
没弹出一点也不反常,如6楼所言,AfxMessageBox要显示在线程的主窗口上,对话框程序中,对话框就是这个线程的主窗口,你关闭了这个主窗口,AfxMessageBox自然无法显示了

热点排行