title: Is calling ShowModal with setting PopupParent a good idea and is it necessary in newer Delphi versions?
body: <p>To prevent newly created modal windows to become hidden under their modal parent window I got used to always set <code>PopupParent</code> when calling <code>ShowModal</code> (as adviced <a href="https://stackoverflow.com/questions/2997079/delphi-how-to-prevent-forms-msgboxes-to-move-under-prior-form">here</a>, <a href="https://stackoverflow.com/questions/743713/newly-created-modal-window-loses-focus-and-become-inacessible-in-windows-vista">here</a> and <a href="https://stackoverflow.com/questions/1639125/form-is-hidden-behind-other-forms-when-showmodal-is-called">here</a>):</p>
  
  <pre><code>function TMyForm.ShowModal(ParentForm: TCustomForm): Integer;
  begin
      PopupParent := ParentForm;
      Result := inherited ShowModal;
  end;
  </code></pre>
  
  <p>But when debugging (a problem of lost form placement, set in FormCreate) I realized that setting <code>PopupParent</code> leads to a call to <code>ReCreateWindow</code>, thus destroying and recreating the underlying Windows screen object.</p>
  
  <p>My questions:</p>
  
  <ol>
  <li>Is it a good idea to always set <code>PopupParent</code> - what might be
  resulting problems? Do viable alternatives exist?</li>
  <li>Is this still necessary in newer versions of
  Delphi (I am using D2006 at the moment but plan to update)?</li>
  </ol>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I think all the linked questions above tackle the same problem, which is best described by the <a href="https://stackoverflow.com/questions/1639125/form-is-hidden-behind-other-forms-when-showmodal-is-called">3rd link</a>:</p>
  
  <blockquote>
    <p>[A form is opened] with ShowModal, this form opens another with ShowModal, so we 
    have stacked modal forms. There is sometimes a problem that when we call ShowModal 
    in new form, it hides behind previous forms, instead of showing on top. After pressing 
    alt+tab, form comes back to the top [...]</p>
  </blockquote>