title: MFC, How to close Modal Dialogs from Main Window?
body: <p>We have a dialog <code>X</code>, that can be opened by different threads (also main thread) as modal. Multiple modal <code>X</code> dialogs, at the same time from different threads is possible.</p>
  
  <p>We want to close all <code>X</code> (only <code>X</code>) modal dialogs, if the main window handles a <code>SC_CLOSE</code> message.</p>
  
  <p>The question is; From the main window, how can we close all modal <code>X</code> dialogs, when it recieves the <code>SC_CLOSE</code> message? Only <code>X</code>! So, <code>PostQuitMessage</code> doesn't help, because it closes whole app, we don't want to close the app, if other modal dialogs like <code>Y, Z ...</code> are opened.</p>
  
  <p>Info: Main window can handle <code>SC_CLOSE</code> message, when we have the opened modal <code>X</code> dialog from main thread also from other threads. And <code>X</code> has no child modal window.</p>