Link to home
Start Free TrialLog in
Avatar of Vickio
Vickio

asked on

wm_activate - why is hwndPrevious null?

hey..
i need to get the handle of the window that is taking focus from my window... wm_activate is what i should use but hwndPrevious is always null..
docs say that 'This handle can be NULL' which doesnt tell me a whole lot :)
what do i do to get the hwnd?
thanks
-vickio
Avatar of JMu
JMu

This is a quess. It's null, when window of an another process is acticated and not null when window of the same process is activated.

You could try GetActiveWindow in WM_ACTIVATE.

JMu
Avatar of Vickio

ASKER

hmm, yeah your right, the window being activated must be of the same process....
calling GetActiveWindow doesnt work though cause WM_ACTIVATE is called before the window loses focus...

anyone else have an idea on how i can do this? if not i'll give JMu the points.

-vickio
ASKER CERTIFIED SOLUTION
Avatar of JMu
JMu

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Vickio

ASKER

cool, GetForegroundWindow works perfect :)
thanks
-vickio
GetFocus() maybe of assistance - the return value is the handle to the window with the keyboard focus. If the calling thread's message queue does not have an associated window with the keyboard focus, the return value is NULL.

Even if GetFocus returns NULL, another thread's queue may be associated with a window that has the keyboard focus.

Use the GetForegroundWindow function to retrieve the handle to the window with which the user is currently working. You can associate your thread's message queue with the windows owned by another thread by using the AttachThreadInput function.

Let me know how you go

DarrinE