• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 260
  • Last Modified:

SetForegroundWindow in Win2K and WinXP

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
svvada
Asked:
svvada
2 Solutions
 
mikelittlewoodCommented:
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
 
pcsentinelCommented:
use
        ShowWindow([Window.Handle], SW_RESTORE);

regards
0
 
svvadaAuthor Commented:
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
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
pcsentinelCommented:
Still works though

regards
0
 
_Katka_Commented:
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
 
ZhaawZSoftware DeveloperCommented:
Is your form minimized or what?
SetForegroundWindow() works fine for me on XP.
0
 
MadshiCommented:
(1) GetForegroundWindow
(2) GetWindowThreadProcessId
(3) AttachThreadInput(GetCurrentThreadId, (2))
(4) SetForegroundWindow
(5) AttachThreadInput(detach)
0
 
svvadaAuthor Commented:
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
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.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

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