Solved

wm_activate - why is hwndPrevious null?

Posted on 2000-02-17
5
446 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

726 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