Solved

wm_activate - why is hwndPrevious null?

Posted on 2000-02-17
5
425 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
cool, GetForegroundWindow works perfect :)
thanks
-vickio
0
 
LVL 2

Expert Comment

by:DarrinE
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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 …
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now