To prevent newly created modal windows to become hidden under their modal parent window I got used to always set PopupParent
when calling ShowModal
(as adviced here, here and here):
function TMyForm.ShowModal(ParentForm: TCustomForm): Integer;
begin
PopupParent := ParentForm;
Result := inherited ShowModal;
end;
But when debugging (a problem of lost form placement, set in FormCreate) I realized that setting PopupParent
leads to a call to ReCreateWindow
, thus destroying and recreating the underlying Windows screen object.
My questions:
- Is it a good idea to always set
PopupParent
- what might be resulting problems? Do viable alternatives exist? - Is this still necessary in newer versions of Delphi (I am using D2006 at the moment but plan to update)?
EDIT:
I think all the linked questions above tackle the same problem, which is best described by the 3rd link:
[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 [...]