[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3169
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

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