Solved

keeping non-modal dialog on top of the main form

Posted on 2007-03-20
4
285 Views
Last Modified: 2010-04-05
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.
0
Comment
Question by:DSOM
  • 2
4 Comments
 
LVL 21

Expert Comment

by:ziolko
ID: 18762541
you can try this:

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

ziolko.
0
 

Expert Comment

by:dopors
ID: 18768816
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.
0
 

Author Comment

by:DSOM
ID: 18775062
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.

0
 
LVL 21

Accepted Solution

by:
ziolko earned 500 total points
ID: 18798535
try this:
procedure TForm1.FormActivate(Sender: TObject);
begin
  if (not Form2.Visible) then
    Form2.Show;
  PostMessage(Form2.Handle, WM_ACTIVATE, WA_ACTIVE, 0);
end;

ziolko.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now