Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to put window to front in WinXP

Status
Not open for further replies.

ResetSystem4

Technical User
Aug 8, 2002
21
AT
Hi all,

i have the following problem:
we have programmed a client application in VC that pops into the front if some events occur, using SetForegroundWindow().
That was working fine until Win2K, but in WinXP it doesn't work anymore.
Could anybody help me out please?
What do i have to change to make that work again?

Thanks in advance,
RS4
 
strange - it should NOT work in Win2k, too, quote from the Win32 doc:

Windows NT 5.0 and later: An application cannot force a window to the foreground while the user is working with another window. Instead, SetForegroundWindow will activate the window (see SetActiveWindow) and call theFlashWindowEx function to notify the user.

"Windows NT 5.0" means "Windows 2000".

So there seems no direct solution for that problem... ?
 
Code:
HWND hCurrWnd;
int iMyTID;
int iCurrTID;
hCurrWnd = ::GetForegroundWindow();
iMyTID   = GetCurrentThreadId();
iCurrTID = GetWindowThreadProcessId(hCurrWnd,0);
AttachThreadInput(iMyTID, iCurrTID, TRUE);
SetForegroundWindow(hWnd);
AttachThreadInput(iMyTID, iCurrTID, FALSE);
HTH

--- markus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top