Solved

Bring to Front

Posted on 1998-10-18
6
3,141 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

690 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