954,176 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to make a window an active window(focussed window)

On windows operating system How can we make a window an active window (focussed window) using c/c++ programming.
I tried using SetForegroundWindow() but it is not working.
AllowSetForegroundWindow() will work on Windows XP?

Any how please give me an idea regaurding this.

ravinderreddy
Newbie Poster
3 posts since Jul 2005
Reputation Points: 10
Solved Threads: 0
 

before you call that you must satisfy the conditions of SetForegroundWindow. This is easiest if you use SystemParametersInfo() to change the value of SPI_SETFOREGROUNDLOCKTIMEOUT to 0. Then SetForegroundWindow will work.

Stoned_coder
Junior Poster
164 posts since Jul 2005
Reputation Points: 19
Solved Threads: 5
 

oh yeah dont forget to set it back to what it was after the call to SetForegroundWindow() so that the OS behaves as it should.

Stoned_coder
Junior Poster
164 posts since Jul 2005
Reputation Points: 19
Solved Threads: 5
 

The SetActiveWindow function might also come in handy.

Dante Shamest
Light Poster
46 posts since Apr 2003
Reputation Points: 13
Solved Threads: 0
 

Your pm box is full ravin.
You may have an outdated sdk which is why this might not work for you. Try downloading latest platform sdk.

SPI_GETFOREGROUNDLOCKTIMEOUT is #defined as 0x2000
SPI_SETFOREGROUNDLOCKTIMEOUT is #defined as 0x2001

So you could try this...

DWORD timeout;
SystemParametersInfo(0x2000,0,&timeout,0);
SystemParametersInfo(0x2001,0,0,SPIF_SENDWININICHANGE | SPIF_UPDATEINIFILE);
SetForegroundWindow(hwnd);
SystemParametersInfo(0x2001,0,&timeout,SPIF_SENDWININICHANGE | SPIF_UPDATEINIFILE);
Stoned_coder
Junior Poster
164 posts since Jul 2005
Reputation Points: 19
Solved Threads: 5
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You