Solved

keeping non-modal dialog on top of the main form

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

828 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