Board index » delphi » Always On Top with a twist !!

Always On Top with a twist !!

Can anyone help me please.

I have the usual 'How do I keep my form on top of all other question'
which I can resolve with SetWindowPos(Form1.Handle, HWND_TOPMOST
,0,0,0,0, SWP_NOMOVE OR SWP_NOACTIVATE OR SWP_NOSIZE), but as soon as
I open a dialog or another window from Form1, things start to go
wrong.

How can I setup my application so that it is topmost in the Z Order
and all its windows 'Stay on Top'.

To set the scene its a small enquiry system that runs in about a
quarter of the desktop, but it must stay in front of everything else,
but the application generates Dialogs and has one ShowModal form.

Help much appreciated :-))

 

Re:Always On Top with a twist !!


Why not set the FormStyle to fsStayOnTop

On 22 Aug 2001 02:06:03 -0700, Steve.Phill...@landreg.gsi.gov.uk

Quote
(Steve Phillips) wrote:
>Can anyone help me please.

>I have the usual 'How do I keep my form on top of all other question'
>which I can resolve with SetWindowPos(Form1.Handle, HWND_TOPMOST
>,0,0,0,0, SWP_NOMOVE OR SWP_NOACTIVATE OR SWP_NOSIZE), but as soon as
>I open a dialog or another window from Form1, things start to go
>wrong.

>How can I setup my application so that it is topmost in the Z Order
>and all its windows 'Stay on Top'.

>To set the scene its a small enquiry system that runs in about a
>quarter of the desktop, but it must stay in front of everything else,
>but the application generates Dialogs and has one ShowModal form.

>Help much appreciated :-))

Re:Always On Top with a twist !!


Did try that to no avail, also you can;t set this property on dialogs ??

Re:Always On Top with a twist !!


You can 'roll your own' dialogs - but to be realistic, if you are
dominating one quarter of the screen, should you then be creating new
forms (including dialogs) that dominate even more ?

I would be inclined to have something like this as a 'self contained'
thing.

Certainly with one form set to foStayOnTop - it stays there - like
glue - you could always do this sort thing:

procedure TForm1.Button1Click(Sender: TObject);
Var
  F : TForm1;
  X : Integer;
begin
  F := TForm1.Create( Form1 );
  X := F.ShowModal ;
end;

end.

On 22 Aug 2001 09:29:10 -0700, Steve.Phill...@landreg.gsi.gov.uk

Quote
(Steve Phillips) wrote:
>Did try that to no avail, also you can;t set this property on dialogs ??

Re:Always On Top with a twist !!


If you want all your windows to stay on top then you can add something
like this to the OnCreate handler of your main form

for I := 0 to Application.ComponentCount - 1 do
  begin
    C := Application.Components[I];
    if C is TForm then
      (C as TForm).FormStyle = fsStayOnTop;
  end;

Quote
>Can anyone help me please.

>I have the usual 'How do I keep my form on top of all other question'
>which I can resolve with SetWindowPos(Form1.Handle, HWND_TOPMOST
>,0,0,0,0, SWP_NOMOVE OR SWP_NOACTIVATE OR SWP_NOSIZE), but as soon as
>I open a dialog or another window from Form1, things start to go
>wrong.

>How can I setup my application so that it is topmost in the Z Order
>and all its windows 'Stay on Top'.

>To set the scene its a small enquiry system that runs in about a
>quarter of the desktop, but it must stay in front of everything else,
>but the application generates Dialogs and has one ShowModal form.

>Help much appreciated :-))

Re:Always On Top with a twist !!


Tried all these to no avail. Just don't work ?? I've seen this sort of
functionality in progs like Winzip where you can keep the whole
application at the top of the Z Order, but how to do it ????

Re:Always On Top with a twist !!


On 23 Aug 2001 02:19:13 -0700, Steve.Phill...@landreg.gsi.gov.uk

Quote
(Steve Phillips) wrote:
>Tried all these to no avail. Just don't work ?? I've seen this sort of
>functionality in progs like Winzip where you can keep the whole
>application at the top of the Z Order, but how to do it ????

You have to use SetWindowPos (or whatever it is). The "topmost"
property in Delphi does not make a topmost window in the sense
I think you want, it just makes a window that will stay above
all the other windows in your application.

You need SetWindowPos for every single window that you want
to make always on top.

David C. Ullrich

Re:Always On Top with a twist !!


On Thu, 23 Aug 2001 14:09:41 GMT, ullr...@math.okstate.edu (David C.

Quote
Ullrich) wrote:

>You need SetWindowPos for every single window that you want
>to make always on top.

And you need to keep it there - because other things might nick your
'rank'.

Other Threads