[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

SetForegroundWindow in Win2K and WinXP

Posted on 2005-05-13
9
Medium Priority
?
257 Views
Last Modified: 2010-04-04
Using the SetForegroundWindow function in Win2000 or WinXP doesn't bring the form to front but only flashes it on the taskbar. How can I get a form to come to the front without screwing around with the users registry settings?
0
Comment
Question by:svvada
9 Comments
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 13996221
Are you trying to bring the form of your delphi application to the front? or another application running on windows?

If it is your own application then you should be able to call:

  Form1.BringToFront;
0
 
LVL 11

Expert Comment

by:pcsentinel
ID: 13996242
use
        ShowWindow([Window.Handle], SW_RESTORE);

regards
0
 
LVL 1

Author Comment

by:svvada
ID: 13996501
Thanks  for the response.
Yes in this case it's from my own application, but the BringToFront and ShowWindow only works if i have focus on my application. If I have focus on another application it just happens in the background. Just to clearify, since the SW_RESTORE is used for restoring a minimized window, my window is not minimized it's just behind other windows, some from other applications.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 11

Expert Comment

by:pcsentinel
ID: 13996555
Still works though

regards
0
 
LVL 10

Expert Comment

by:_Katka_
ID: 13997072
Hi, get the handle of your window or either
window of different application and use fn:

function BringWindowToTop(hWnd: HWND): BOOL; stdcall;

BringWindowToTop([Window.Handle]);

regards,
Kate
0
 
LVL 11

Expert Comment

by:ZhaawZ
ID: 13999837
Is your form minimized or what?
SetForegroundWindow() works fine for me on XP.
0
 
LVL 20

Accepted Solution

by:
Madshi earned 1000 total points
ID: 14001649
(1) GetForegroundWindow
(2) GetWindowThreadProcessId
(3) AttachThreadInput(GetCurrentThreadId, (2))
(4) SetForegroundWindow
(5) AttachThreadInput(detach)
0
 
LVL 3

Assisted Solution

by:smot
smot earned 1000 total points
ID: 14002749
0
 
LVL 1

Author Comment

by:svvada
ID: 14034305
Thanks again for all the response, sorry about the delayed feedback but I've had a looooong weekend.
pcsentinel: It might work for you, but it's not working for me. Might have something to do with reg settings?
Kate: Same thing here, it just flashes on the taskbar.
ZhaawZ: When i write "my window is not minimized" it's not minimized (= And again it's not working for me.
Madshi: Perfect! Just what I needed!
smot: Link would not open, looks like the site is down, might also have been a good solution.
I'll wait a while and try the link again before I distribute out the points. fair is fair.

Again thanks for all your help.
0

Featured Post

Technology Partners: 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!

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month19 days, 1 hour left to enroll

834 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