Board index » delphi » TForm.formStyle := fsStayOnTop

TForm.formStyle := fsStayOnTop

I want to be able to hide my main form, and display another form as a
StayOnTop form above all other Windows Applications.  But each time I create
the 2nd for and hide the Main form, my Second form looses its StayOnTop
style.

Is it not possible to have your program StayOnTop when the MainForm is
hidden?

Thanks.

Bob

 

Re:TForm.formStyle := fsStayOnTop


Quote
In article <3d347cf0$1_1@dnews>, Bob wrote:
> I want to be able to hide my main form, and display another form as a
> StayOnTop form above all other Windows Applications.  But each time I create
> the 2nd for and hide the Main form, my Second form looses its StayOnTop
> style.

> Is it not possible to have your program StayOnTop when the MainForm is
> hidden?

Try this: override the second forms Createparams method:

  public
    { Public declarations }
    procedure CreateParams(var Params: TCreateParams); override;

procedure TForm2.CreateParams(var Params: TCreateParams);
begin
  inherited CreateParams(Params);
  Params.wndParent := GetDesktopWindow;
  params.Exstyle := params.Exstyle or WS_EX_TOPMOST;
end;

Use a bsDialog borderstyle if the form should not have its own taskbar button
(it will get one if it is owned by the desktop).

--
Peter Below (TeamB)  
Use the newsgroup archives :
http://www.mers.com/searchsite.html
http://www.tamaracka.com/search.htm
http://groups.google.com
http://www.prolix.be

Re:TForm.formStyle := fsStayOnTop


Thanks Peter.  I'll give it a try.

"Peter Below (TeamB)" <100113.1...@compuXXserve.com> wrote in message
news:VA.00008f00.00f144f2@antispam.compuserve.com...

Quote
> In article <3d347cf0$1_1@dnews>, Bob wrote:
> > I want to be able to hide my main form, and display another form as a
> > StayOnTop form above all other Windows Applications.  But each time I
create
> > the 2nd for and hide the Main form, my Second form looses its StayOnTop
> > style.

> > Is it not possible to have your program StayOnTop when the MainForm is
> > hidden?

> Try this: override the second forms Createparams method:

>   public
>     { Public declarations }
>     procedure CreateParams(var Params: TCreateParams); override;

> procedure TForm2.CreateParams(var Params: TCreateParams);
> begin
>   inherited CreateParams(Params);
>   Params.wndParent := GetDesktopWindow;
>   params.Exstyle := params.Exstyle or WS_EX_TOPMOST;
> end;

> Use a bsDialog borderstyle if the form should not have its own taskbar
button
> (it will get one if it is owned by the desktop).

> --
> Peter Below (TeamB)
> Use the newsgroup archives :
> http://www.mers.com/searchsite.html
> http://www.tamaracka.com/search.htm
> http://groups.google.com
> http://www.prolix.be

Other Threads