Link to home
Start Free TrialLog in
Avatar of DSOM
DSOMFlag for United States of America

asked on

keeping non-modal dialog on top of the main form

How do you specify that a non-modal dialog should stay on top of the main form?  I don't want it on top of other windows.
Avatar of Lukasz Zielinski
Lukasz Zielinski
Flag of Poland image

you can try this:

procedure TForm1.FormActivate(Sender: TObject);
begin
  if (not Form2.Visible) then
    Form2.Show;
  Form2.BringToFront;
end;

ziolko.
Avatar of dopors
dopors

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
    Form2: TForm;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  Form2 := TForm.Create(Self);
  with Form2 do begin
    FormStyle := fsStayOnTop;
    Show;
  end;
end;

end.
Avatar of DSOM

ASKER

the fsstayontop attribute makes the window stay on top of all windows not just the parent window.  the bringtofront does not make it stay on top.

ASKER CERTIFIED SOLUTION
Avatar of Lukasz Zielinski
Lukasz Zielinski
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial