简体   繁体   English

当模式对话框没有焦点时,MFC EndDialog崩溃

[英]MFC EndDialog crashes when modal dialog does not have focus

I am closing a modal dialog after I end a task, inside a separate thread from where I created a modal dialog: 结束任务后,我将在与创建模态对话框的位置不同的线程内关闭模态对话框:

void CmodguiApp::_notify_task_end() {
  processingDialog->EndDialog(0);
}

This works fine if my application has focus (therefore the modal dialog has focus). 如果我的应用程序具有焦点(因此,模式对话框具有焦点),这将很好地工作。 But this causes the application to crash if I change window while the modal dialog is on (for instance, if I leave the application processing and switch to Firefox or so). 但是,如果在模式对话框打开时更改窗口,这会导致应用程序崩溃(例如,如果我离开应用程序处理并切换到Firefox左右)。

What could be wrong? 有什么事吗

Do not end the dialog with EndDialog. 不要以EndDialog结束对话框。 Instead PostMessage with WM_CLOSE or WM_QUIT to the dialog window. 而是将带有WM_CLOSE或WM_QUIT的PostMessage发送到对话框窗口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM