Solved

Bring to Front

Posted on 1998-10-18
6
3,126 Views
Last Modified: 2012-06-27
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
Comment
Question by:ponti
6 Comments
 
LVL 3

Accepted Solution

by:
philipleighs earned 100 total points
ID: 1343294
Hi,

Add WinTypes and WinProcs to your uses clause.

Use:
SetForeGroundWindow(Form1.Handle);

Cheers,
Phil.

0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1343295
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
 

Author Comment

by:ponti
ID: 1343296
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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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.

 
LVL 3

Expert Comment

by:bryan7
ID: 1343297
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
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1343298
Have you tried setting the active property to true?
0
 
LVL 3

Expert Comment

by:philipleighs
ID: 1343299
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question