Delphi<=8 Forms Z-order

https://stackoverflow.com/questions/2997079/delphi-how-to-prevent-forms-msgboxes-to-move-under-prior-form

 

For old versions of delphi (prior to Delphi 2007), on forms OTHER than your main form:

interface

TMyForm = Class(TForm)

protected

procedure CreateParams(var Para: TCreateParams); override;

end;

...

implementation

...

procedure TMyForm.CreateParams(var Para: TCreateParams);

begin

inherited;

Para.Style := Para.Style or WS_POPUP;

{ WinXP Window manager requires this for proper Z-Ordering }

// Para.WndParent:=GetActiveWindow;

Para.WndParent := Application.MainForm.Handle;

end;

For message boxes include MB_TOPMOST in your flags:

Application.MessageBox(PChar(amessage), PChar(atitle), otherflags or MB_TOPMOST);

原文地址:https://www.cnblogs.com/jspdelphi/p/8572070.html