DSOM
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.
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.
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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
procedure TForm1.FormActivate(Sender
begin
if (not Form2.Visible) then
Form2.Show;
Form2.BringToFront;
end;
ziolko.