manatttta
manatttta

Reputation: 3124

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).

What could be wrong?

Upvotes: 0

Views: 885

Answers (1)

hypheni
hypheni

Reputation: 816

Do not end the dialog with EndDialog. Instead PostMessage with WM_CLOSE or WM_QUIT to the dialog window.

Upvotes: 1

Related Questions