Lift Tkinter window on Win32

Alex a_slusarczyk at hotmail.com
Thu Sep 20 07:06:35 EDT 2001


a_slusarczyk at hotmail.com (Alex) wrote in message news:<6f1556e6.0109190529.1ff97f7f at posting.google.com>...
> I have not found the solution yet, but for those of you, who have
> similar problem, it seems that the culprit is the following:
> 
> (quote form http://support.microsoft.com/directory/article.asp?ID=KB;EN-US;Q227043)
> 
> "If you design an application for Windows 98 and/or Windows 2000 with
> the assumption that you can always take over the active window, your
> application may fail. If your application tries to take over the
> foreground under restricted conditions, your application flashes in
> the user's taskbar. Your application can take over the foreground
> under one of the following conditions ..."
> 
> Indeed, SetForegroundWindow causes the target window to flash on the
> taskbar...
> 
> Alex

Seems like I'm monopolyzing this thread but I thought that after two
days
of trying to figure out the matter, there may be at least one poor
soul interested in what I have come up with.

Since I still have no success in calling window.lift(), I've gone with
:

hwnd = string.atoi( window.frame(), 0 )
win32gui.SetForegroundWindow( hwnd )

On Win98 (and reportedly on W2k), however, the nasty foreground window
restriction messes up things. To circumvent that, I ran the following
C code:

#ifndef SPI_SETFOREGROUNDLOCKTIMEOUT 
// older version of winuser.h doesnt have it defined
#define SPI_SETFOREGROUNDLOCKTIMEOUT 0x2001
#endif

SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, (LPVOID)0,      
               SPIF_SENDWININICHANGE | SPIF_UPDATEINIFILE);

which apparently switches off some sort of
foreground-setting-lock-timeout-thing

Hope it helps someone out there.
BTW, I would still be interested in solution/explanation of the
.lift() problem.

Alex



More information about the Python-list mailing list