[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3177
  • Last Modified:

Bring to Front

How can i bring my application written in delphi 1 to the front when another windows has openend in front of mine?
(Method Active doesn't work)
0
ponti
Asked:
ponti
1 Solution
 
philipleighsCommented:
Hi,

Add WinTypes and WinProcs to your uses clause.

Use:
SetForeGroundWindow(Form1.Handle);

Cheers,
Phil.

0
 
rwilson032697Commented:
The active property determines whether your application has focus. Use MyMainForm.BringToFront to make your application active again. You could have a check in the OnIdle event handler of the TApplication object to check this automatically and keep your application in the front.

On the other hand, if you have a specific form that you always want to be in front of all the others then set its FormStyle to fsStayOnTop
0
 
pontiAuthor Commented:
Both hints don't work. It is not a mdi child within my app, which should be in front of the others. Another app is in front of mine and i would like to bring my app to the front (delphi 1). What works when i set the formstyle to "stayontop". but when i reset the formstyle right after the app goes back to the background.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
bryan7Commented:
hmm... I'm not sure, what happens if you drop a timer and every 4 or 5 seconds
 you set the formstyle as StayOnTop ?

bryan

0
 
rwilson032697Commented:
Have you tried setting the active property to true?
0
 
philipleighsCommented:
Hi,

I just created a new application in delphi, added a TTimer to the form and set the interval to 3000.

In the OnTimer event I call
SetForeGroundWindow(Application.Handle);

and then run the app. I alt tab to another program, and within 3 seconds the app is brought to the front.

Works for me.

PS:
If your form is minimised then it won't work. If this is the case the call
ShowWindow(Application.Handle, SW_RESTORE);
before SetForeGroundWindow.

PS2:
Prehaps you need Application.Handle, not just Handle which is the main form handle.

Cheers,
Phil.


0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now