Is this reaaly so, and then, how do I get the active window?
Regards, Ted
To get the handle of the foreground window, you use the cunningly-hidden
GetForegroundWindow()
--
Lucian
>I Win16, the API function GetActiveWindow gives me the handle of the active
>window.
>In Win32 however, GetActiveWindow only gives me the "handle of the active
>window associated with the thread that calls the function.", and appearently I
>can not find the active window on the screen, only the active window of my
>thread.
>Is this reaaly so, and then, how do I get the active window?
>Regards, Ted
GetActiveWindow returns the HWND of the active window on a TASK basis,
I believe. I cannot comment as to whether threads in a task play any
part, as I have only ever used threads to implement worker functions,
and not fire up complete window procedures. Although I am not A1
totally sure, GetActiveWindow now acts in a similar way to
GetLastActivePopup. The call you want is GetForegroundWindow. This
returns the HWND of the window which actually has the highlighted
caption bar and, usually, the user input focus - although experience
has shown that it is possible for an inactive window of an MDI client
to have focus and not be the window which appears to have it.
This may be overkill, but I have found that the following always gets
the window handle of the really, truely, kosher active window:
hActive = GetLastActivePopup(GetForegroundWindow())
Jim
-------------------------------------------------------------
Jim Hoggarth, Bradford, UK hogg...@nildram.co.uk
Author of the 'Screen Thief' range of screen capture products
for DOS, Win31 and Win95 (ASP). See http://www.nildram.co.uk
-------------------------------------------------------------
>I Win16, the API function GetActiveWindow gives me the handle of the active
>window.
>In Win32 however, GetActiveWindow only gives me the "handle of the active
>window associated with the thread that calls the function.", and appearently I
>can not find the active window on the screen, only the active window of my
>thread.
>
>Is this reaaly so, and then, how do I get the active window?
You might want to take a look at
http://www.r2m.com/win-developer-FAQ/windows/7.html
rm
---
Robert Mashlan R2M Software rmas...@r2m.com
Internet Resources for Windows Developers http://www.r2m.com/windev/
>In Win32 however, GetActiveWindow only gives me the "handle of the active
>window associated with the thread that calls the function.", and appearently I
>can not find the active window on the screen, only the active window of my
>thread.
>Is this realy so, and then, how do I get the active window?
Yes, it's really so. We use a CBT hook to monotor system wide window
activations.
Mike Philben
>Regards, Ted
The answer to my specific question (cited above) is to use
GetForegroundWindow which seems to give me the correct handle.
Regards, Ted