Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SetForegroundWindow()

115 views
Skip to first unread message

Alessandro Oddera

unread,
Aug 4, 1998, 3:00:00 AM8/4/98
to
The SetForegroundWindow don't work, it don't puts the thread that
created the specified window into the foreground and activates the
window, it merely flash the window.

Do anyone know a way to puts the thread into the foreground, and
activates the window?

Please reply with EMail.


please remove NOSPAM from email address to write me.
/-------------------------------------------------------\
| DataDuck 5.1 Configurable DataBase and Plug-in Win95 |
| also for Windows 3.1 and NT. Aim your Web browser at |
| http://www.prog.arch.unige.it/~aoddera/Homeao.htm |
| to get your own copy! |
\-------------------------------------------------------/

Dave Postill

unread,
Aug 4, 1998, 3:00:00 AM8/4/98
to
[This followup was posted to comp.os.ms-windows.programmer.win32 and a
courtesy copy was sent to the cited author, Alessandro Oddera]

On Tue, 04 Aug 1998 00:06:20 GMT, Alessandro Oddera wrote:

| The SetForegroundWindow don't work, it don't puts the thread that
| created the specified window into the foreground and activates the
| window, it merely flash the window.
|
| Do anyone know a way to puts the thread into the foreground, and
| activates the window?

The answer was posted a couple of days ago:

On Sun, 02 Aug 1998 14:39:23 -0700, in comp.os.ms-windows.programmer.win32
David Ching wrote:

| mdb...@my-dejanews.com wrote:
| >
| > In article <6ocl3f$n3d$1...@news.seed.net.tw>,
| > "kgb" <k...@iii.org.tw> wrote:
| >
| > > I have found that if I switch to another application's window after the
| > > WM_LBUTTONDOWN was sent, my
| > > window would not be brought to foregound instead it is been high light on
| > > the taskbar.
| > >
| >
|
| Problem here is Win98 (and NT 5) trying to be smart. If you have used
| the mouse or keyboard within the last n milliseconds, then try to do a
| SetForegroundWindow to a window of another task, Windows flashes the
| taskbar button instead of activating the window. The trick is to
| disable the feature prior to SetForegroundWindow(), then re-enabling it
| immediately so that it is transparent to your users:
|
| // Save specified timeout period...
| DWORD dwTimeoutMS;
| SystemParametersInfo (SPI_GETFOREGROUNDLOCKTIMEOUT, 0, &dwTimeoutMS, 0);
|
| // ... then set it to zero to disable it
| SystemParametersInfo (SPI_SETFOREGROUNDLOCKTIMEOUT, 0, (PVOID) 0, 0);
|
| // Do the SetForegroundWindow
| SetForegroundWindow (hwndDesiredWindow);
|
| // ... then set it back
| SystemParametersInfo (SPI_SETFOREGROUNDLOCKTIMEOUT, 0, (PVOID)
| dwTimeoutMS, 0);
|
|
| --
| David Ching, Windows Consultant
| DC Software Design, Inc.
| http://www.dcsoft.com


davep
--
--
Dave Postill Investment Intelligence Systems Corp
Galaxy Support Leader +44 (0)171 628 6960 [voice]
da...@iisc.co.uk [business] +44 (0)171 638 7528 [fax]
dave.p...@pobox.com [personal] http://www.iisc.co.uk

Alessandro Oddera

unread,
Aug 4, 1998, 3:00:00 AM8/4/98
to
da...@iisc.co.uk (Dave Postill) wrote:

I don't know the values for
SPI_GETFOREGROUNDLOCKTIMEOUT
and for
SPI_SETFOREGROUNDLOCKTIMEOUT
do anyone tell me these values?

Thank you.

>|
>| --
>| David Ching, Windows Consultant
>| DC Software Design, Inc.
>| http://www.dcsoft.com
>
>
>davep
>--
>--
>Dave Postill Investment Intelligence Systems Corp
>Galaxy Support Leader +44 (0)171 628 6960 [voice]
>da...@iisc.co.uk [business] +44 (0)171 638 7528 [fax]
>dave.p...@pobox.com [personal] http://www.iisc.co.uk

please remove NOSPAM from email address to write me.

David Ching

unread,
Aug 5, 1998, 3:00:00 AM8/5/98
to NOSPAM...@unige.it
Alessandro Oddera wrote:
>
> I don't know the values for
> SPI_GETFOREGROUNDLOCKTIMEOUT
> and for
> SPI_SETFOREGROUNDLOCKTIMEOUT
> do anyone tell me these values?
>
> Thank you.
>

// New flags for Win98/NT5 not yet defined in VC 5 winuser.h
#define SPI_GETFOREGROUNDLOCKTIMEOUT 0x2000
#define SPI_SETFOREGROUNDLOCKTIMEOUT 0x2001

0 new messages