Board index » delphi » Creating a form with stayontop

Creating a form with stayontop

I'm opening a modeless form that I want to stay on top of my main
application form. But I don't want this "stay on top form" to stay on top
of any other applications that I might be running. To put it in another
way, I want this form to be the topmost form if my delphi application is
active, but if another application, (i.e. ms word) is the active window, I
don't want this "stay on top form" floating on top of it.

There doesn't seem to be any combination of properties to set to make this
happen. Do I have to do something with the Windows API?

 

Re:Creating a form with stayontop


Quote
"Eric Johnson" <ejohn...@unitedwww.com> wrote:

WS_EX_TOPMOST (in terms of which I'm guessing fsStayOnTop is
implemented) definitely is no respecter of who's who.  I would think a
couple of things you might try are:

1) Making the window modal, which would bring it to the top to follow
the application.

2) Handling the "parent" form's OnActivate, calling Activate on the
modless window you want to be on top.  If that doesn't work you might
look into SetWindowPos on the latter.

Quote
>I'm opening a modeless form that I want to stay on top of my main
>application form. But I don't want this "stay on top form" to stay on top
>of any other applications that I might be running. To put it in another
>way, I want this form to be the topmost form if my delphi application is
>active, but if another application, (i.e. ms word) is the active window, I
>don't want this "stay on top form" floating on top of it.
>There doesn't seem to be any combination of properties to set to make this
>happen. Do I have to do something with the Windows API?

------------------------

John Lockwood Consulting
http://www.jlockwood.com

Other Threads