Solved

keeping non-modal dialog on top of the main form

Posted on 2007-03-20
4
289 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi : could not find program, '...exe' 2 171
Show Listview image from database (String field) 5 127
Firemonkey allowing RTL on android 6 33
MS Access from Delphi 31 32
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

803 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