Link to home
Start Free TrialLog in
Avatar of svvada
svvada

asked on

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?
Avatar of Mike Littlewood
Mike Littlewood
Flag of United Kingdom of Great Britain and Northern Ireland image

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;
Avatar of pcsentinel
pcsentinel

use
        ShowWindow([Window.Handle], SW_RESTORE);

regards
Avatar of svvada

ASKER

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.
Still works though

regards
Avatar of _Katka_
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
Is your form minimized or what?
SetForegroundWindow() works fine for me on XP.
ASKER CERTIFIED SOLUTION
Avatar of Madshi
Madshi

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of svvada

ASKER

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.