0

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.

3
Contributors
4
Replies
8
Views
12 Years
Discussion Span
Last Post by Stoned_coder
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.

0

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.

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);
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.