Solved

keeping non-modal dialog on top of the main form

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
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…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

911 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

16 Experts available now in Live!

Get 1:1 Help Now