title: How to determine the Z order of multiple visible forms in Delphi?
body: <p>Using Delphi 7. There are, among other components, 4 non-modal visible forms over a TPanel (the TPanel is the parent of the forms). I use Show, Hide, BringToFront, SendToBack on the various forms and it works fine. </p>
  
  <p>The problem is that at any point in time I would like to programmatically determine the Z order of the forms. For example, Form2 is on top, behind that is Form3, then Form1, and last is Form4.</p>
  
  <p>Or put it in a slightly different way: given any two non-modal, visible forms, e.g. Form2 and Form3, how to determine programmatically which one is above the other?</p>
  
  <p>I tried Screen.Forms, but it doesn't work -- it always gives me the forms in the same order, regardless of the actual visible Z-order of the forms.</p>
  
  <p>I read about the Windows functions GetTopWindow and GetNextWindow but before I try to use that, I'd like to know if there is a simpler way. Especially if I just have two forms with the same parent, is there a simple way to know which of them is above the other?</p>
  
  <p>Thanks for any suggestions!</p>