title: Window showing on top of application / VB6
body: <p>I have a VB6 application consisting of a MDI form, MDI child forms and standard forms. This application has been fine running on operating systems before Windows 7 / Windows 2008 Server R2. On Windows 7 / Windows 2008 Server R2, I am having an issue when showing a modal form. The modal form sometimes does not stay at the foreground and a form that was behind it comes to the front, even if it’s another application.</p>
  
  <p>For example, I open Microsoft Word. Then I open my application (the MDI form with an MDI child,) which is on top of Word on the screen.  I click on a button on the MDI child form that calls a modal popup form. Word comes up on the screen and is now the topmost form, but does not have focus and does not respond to any key press events. The modal popup, although behind Word, is responding to the key press. </p>
  
  <p>This does not happen every time, but if I click the button on the MDI child and close the modal form over and over I can cause it to happen at some point.  My users see it a lot because they are going in and out of screens all day.</p>
  
  <p>Any idea of what is causing this?  It is fine on Windows XP.</p>
  
  <p>Code for MDIForm1:</p>
  
  <pre><code>Private Sub MDIForm_Load()
    Form1.Show
  End Sub
  </code></pre>
  
  <p>Code for Form1 (with a single command button):</p>
  
  <pre><code>Private Sub Command1_Click()   
      Form2.Display
  End Sub
  </code></pre>
  
  <p>Code for Form2 (with a single command button)::</p>
  
  <pre><code>Public Sub Display()
    Command1.Caption = "Close Me"
    Me.Show vbModal
  End Sub
  
  Private Sub Command1_Click()
   Unload Me
  End Sub
  </code></pre>