title: Focus With Multiple Dialog Boxes (MFC)
body: <p>I have a problem where clicking (anywhere) on a child dialog box within the application's main frame window causes a message box with NULL parent, which was visible, to be hidden behind the main window.</p>
  
  <p>Say for example we have the following Z order (assuming zero is topmost):</p>
  
  <p>MainWindow = 2, Dialog1 = 1, MessageBox = 0</p>
  
  <p>When I click on Dialog1, it brings MainWindow in front of MessageBox , so we end up with:</p>
  
  <p>MessageBox = 2, MainWindow=1, Dialog1 = 0</p>
  
  <p>But these are both error messages (from different threads) and I don't want the user to acknowledge one then potentially ignore the other because it gets buried.</p>
  
  <p>Some key points:</p>
  
  <ul>
  <li><p>Dialog1 is shown using DoModal() (not overidden) on receipt of a user defined message to MainWindow.</p></li>
  <li><p>MessageBox is shown from a separate thread. It's parent window is NULL. I can't set it's parent to MainWindow because the error can occur when MainWindow is waiting on a response from the function that triggered the error in the first place, which causes deadlock. This deadlock scenario isn't the case here as it happens, but I can't assume that from the thread that creates the message box.</p></li>
  </ul>
  
  <p>I tried adding MB_APPLMODAL to the message box style but it didn't help. I don't want to make it topmost - that just irritates people.</p>
  
  <p>Is there actually a way of preventing MainWindow jumping in front of this message box?</p>
  
  <p>Thanks for any help.</p>