Board index » delphi » How to keep a delphi window ALWAYS on top of ALL windows?

How to keep a delphi window ALWAYS on top of ALL windows?

I have a Delphi project with two forms.  A main form and another form.
The project opens to the main form and when a certain button in clicked,
the main form becomes hidden and the second form becomes visible.  I want
the 2nd form, while it is visible to be ALWAYS ON TOP.  By "on top", I
mean that I want it on top of ALL windows, not just windows in the
project.

NOTE - setting the FormStyle property to fsStayOnTop does NOT work (that
simply would make it stay on top of forms in the current project).

Please Help!?

Clint Watson
cwat...@txdirect.net

 

Re:How to keep a delphi window ALWAYS on top of ALL windows?


Easy. Put this in the form's Activate event.

var selfwnd: integer;
begin
selfwnd := GetActiveWindow;
Setwindowpos(selfwnd, Hwnd_topmost, 0, 0, 0, 0, swp_nomove + swp_nosize);
end;

Its as simple as that.
You might want to consider making a form like that
for the gallery so you don't have to do it every time.

--
To err is human. To really {*word*30} up requires a computer.
-=> Paradox <=-

Re:How to keep a delphi window ALWAYS on top of ALL windows?


In article <40gih8$...@newsbf02.news.aol.com>,
   paradox...@aol.com (ParadoxOS2) wrote:
Quote
>Easy. Put this in the form's Activate event.

>var selfwnd: integer;
>begin
>selfwnd := GetActiveWindow;
>Setwindowpos(selfwnd, Hwnd_topmost, 0, 0, 0, 0, swp_nomove + swp_nosize);
>end;

>Its as simple as that.
>You might want to consider making a form like that
>for the gallery so you don't have to do it every time.

I believe there is a window style in the object inspector that you can set to
AlwaysOnTop.

Re:How to keep a delphi window ALWAYS on top of ALL windows?


In article <40gih8$...@newsbf02.news.aol.com>,
   paradox...@aol.com (ParadoxOS2) wrote:
Quote
>Easy. Put this in the form's Activate event.

>var selfwnd: integer;
>begin
>selfwnd := GetActiveWindow;
>Setwindowpos(selfwnd, Hwnd_topmost, 0, 0, 0, 0, swp_nomove + swp_nosize);
>end;

>Its as simple as that.
>You might want to consider making a form like that
>for the gallery so you don't have to do it every time.

I believe there is a window style in the object inspector that you can set to
AlwaysOnTop.

Other Threads