Solved

wm_activate - why is hwndPrevious null?

Posted on 2000-02-17
5
435 Views
Last Modified: 2013-12-03
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
0
Comment
Question by:Vickio
  • 2
  • 2
5 Comments
 
LVL 1

Expert Comment

by:JMu
ID: 2533930
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
0
 

Author Comment

by:Vickio
ID: 2534154
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
0
 
LVL 1

Accepted Solution

by:
JMu earned 350 total points
ID: 2534215
Oops, GetActiveWindow() is thread specific function. If calling thread does not have active window, it returns NULL.

Looks like you have to call GetForegroundWindow() in WM_ACTIVATE.

Does this work?

JMu
0
 

Author Comment

by:Vickio
ID: 2534239
cool, GetForegroundWindow works perfect :)
thanks
-vickio
0
 
LVL 2

Expert Comment

by:DarrinE
ID: 2534256
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
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question