dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Home » Tip Bank » C++
Language: C++
Expertise: Beginner
May 2, 1999

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


Getting the active window

Question:
I am using VC++ 5.0 to develop applications based on Windows 95. I want to get the HWND of the active window, which is receiving the keyboard or mouse input and is a child window of the foreground window. I used ::getactivewindow(), but it can get only the window associated with my thread. What can I do?

Answer:
It used to be that you'd use GetFocus() to get the handle to the window that is taking user input. But this function has also been changed under Win32 to work only for windows attached to the same thread.

Here's how to globally find the window that has the input focus, according to the Microsoft Platform SDK documentation:

"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."

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date