Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Make Form popup on top - silly question?

Status
Not open for further replies.

ITfromZX81

Programmer
May 18, 2004
151
0
0
CA
Maybe this is a silly question but...

How do I make a Delphi program appear at the top, in front of other windows, at a specified point in the code?

I don't want it to always be on top; I just want it to pop to the top so that the user can see a message when other functions are finished.

I cannot figure out how to do it or what I am doing wrong - it never does this - the user has to click on it in the taskbar to see the message.

Thanks,
 
Delphi forms have a property called FormStyle. This is set to fsNormal by default but you can set it either at design time or run time to fsStayOnTop.

Andrew
Hampshire, UK
 
Lets see if i'm getting you right: you have a form which is minimized and doing some work. You want it to "pop" when the work is done.

Being so, restore the form. You can use ShowWindow(Handle, SW_RESTORE) (check the SDK) or Application.Restore (check Delphi help). Try both to see which fits to your needs best(the last is best if the form is the main form).

buho (A).
 
I'm not sure that you are actually refering to a minimised form. My example is not related to a minimised form.

It's been a while since I wrote some code on this subject but I have found that fsStayOnTop doesn't appear to work, or do anything in my particular version of Delphi6. So I implement a call from the topmost form, say TopForm, to the 'popup' form to call its Self.Show() method. Because I want to keep the form on top whenever this TopForm is active, I put the call to the PopupForm in the FormActivate method of TopForm, there's a little more to it. But this might be relevant to your problem.

TeeeTeee
 
Yup; TeeeTeee have a point. If the form is not minimized, Show is the way to go.

From the D6 help: "Note: It is not advisable to change FormStyle at runtime." I do not use fsStayOnTop too much, but I think it is not to put an actual Window on top but to start a new "stay-on-top" Window. To put an actual Window on top I use SetWindowPos.

buho (A).
 
I guess, if you simply wanted a form on top, you could call 'ShowModal' but this would block all other processing in your application.

For some purposes I use Show() and tie it to formActivate and formDeactivate() but the reason I do this is I don't want the a modal form blocking. My other forms continue to receive input from the topmost form when it is on top.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top