Bring Window to Front (No "Always On Top")

Hello,

How can I bring a window to front once?  No "Always On Top", just bring the window to front once.

Thanks.

rng
rngAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ivanov_GCommented:
if your active form is Form1 then
Form1.BringToFront;

if you want to use it anywhere
if (Self is TForm) then
  (Self as TForm).BringToFront;

you can also use Windows API functions SetForegroundWindow, SetActiveWindow and FlashWindow to achieve something more.
0
rngAuthor Commented:
Could you give an example for using those API function ?

Thanks.
rng
0
esoftbgCommented:
The BringWindowToTop function brings the specified window to the top of the Z order. If the window is a top-level window, it is activated. If the window is a child window, the top-level parent window associated with the child window is activated.

BOOL BringWindowToTop(
    HWND hWnd       // handle to window
   );      

Parameters:
hWnd
Identifies the window to bring to the top of the Z order.
 

Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.

//........ example:

procedure TForm1.SpeedButton3Click(Sender: TObject);
begin
  BringWindowToTop(Form2.Handle);
end;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ivanov_GCommented:
procedure TForm1.Button1Click(Sender: TObject);
begin
  // using TForm's method
  Form1.BringToFront;
  // Set window on foreground
  SetForegroundWindow(Form1.Handle);
  // set active
  SetActiveWindow(Form1.Handle);
  // flash Window
  FlashWindow(Form1.Handle, True);
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  // flash Window
  FlashWindow(Form1.Handle, True);
end;
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.