Board index » delphi » Help StayOnTop

Help StayOnTop

Hai,

I want to let a form stay on top.
Easy : set the formstyle to fsStayOnTop
But I want to do it at run-time.
And you can't set FormStyle at runtime.
The form has to stay on top of other windows, but not on top of all
windows.
Not on top of opendialogs for example.
I use Delphi 3.0 C/S

If you know the answer to my question than please sent it to
tigel...@tref.nl

Many, many thanks in advance.

Yours sincerely,

Almer Tigelaar
tigel...@tref.nl
http://almer.home.ml.org/

 

Re:Help StayOnTop


In article <01bcf391$52113c40$11244...@tigelaar.tref.nl>,
   "A.S. Tigelaar" <tigel...@tref.nl> wrote:

Quote
>Hai,

>I want to let a form stay on top.
>Easy : set the formstyle to fsStayOnTop
>But I want to do it at run-time.
>And you can't set FormStyle at runtime.
>The form has to stay on top of other windows, but not on top of all
>windows.
>Not on top of opendialogs for example.
>I use Delphi 3.0 C/S

>Yours sincerely,

>Almer Tigelaar
>tigel...@tref.nl
>http://almer.home.ml.org/

this is a bit rough, but perhaps the "easiest" way without thinking about it
may be to create two "identical" forms which appear the same to the user
except that one has fsStayOnTop and the other doesn't.  All the procedures on
one form can then call the same ones on the other form to avoid code
duplication.  You can then have a global boolean which determines which form
is displayed.  This would, of course, produce a form which sits on top of ALL
forms on the screen.  You may have to look at somehow setting the Z order of
the form and setting above all the forms you wish to sit above, never done it
myself, but once you find the way to do it, it is probably not too messy.

Wish you luck,

Trevor Hand

Re:Help StayOnTop


On 17 Nov 1997 19:43:38 GMT, "A.S. Tigelaar" <tigel...@tref.nl> wrote:

Quote
>Easy : set the formstyle to fsStayOnTop
>But I want to do it at run-time.
>And you can't set FormStyle at runtime.

Try this:

SetWindowPos(Form1.Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or
             SWP_NOSIZE)

Bye
Andrej

--
email: wi...@tmb.in-berlin.de

Re:Help StayOnTop


Almer,

I'm not sure I fully understand the problem... I use the following
code to make a running application "stay on top" (during runtime),
using a global boolean OnTopToggle variable and a menu item for user
selection:

procedure TForm1.AlwaysOnTopMenuItemClick(Sender: TObject);
begin
     OnTopToggle := not(OnTopToggle);
     AlwaysOnTopMenuItem.Checked := OnTopToggle;

     if (OnTopToggle) = TRUE then
        begin
             Form1.FormStyle := fsStayOnTop;
        end
     else
        begin
             Form1.FormStyle := fsNormal;
        end;
end;

The form will stay in the forefront but may not necessarily be active,
i.e. dialogs from other running programs can still get focus.  Does
this help?

-SynTap

Quote
>Hai,

>I want to let a form stay on top.
>Easy : set the formstyle to fsStayOnTop
>But I want to do it at run-time.
>And you can't set FormStyle at runtime.
>The form has to stay on top of other windows, but not on top of all
>windows.
>Not on top of opendialogs for example.
>I use Delphi 3.0 C/S

>If you know the answer to my question than please sent it to
>tigel...@tref.nl

>Many, many thanks in advance.

>Yours sincerely,

>Almer Tigelaar
>tigel...@tref.nl
>http://almer.home.ml.org/

Other Threads