Jump to content
  • Advertisement
Sign in to follow this  
_nomad_

[WIN32 API] Getting Window ID

This topic is 4517 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

My window is in background, other window in foreground, how do i get its window ID and how do i close that foreground window? thanks.

Share this post


Link to post
Share on other sites
Advertisement
You should know it's handle (HWND) if you created it. Window handles are unique, so you can think of them as "ids". Or, you can use GetActiveWindow to get the active window from the calling thread.

As for closing the foreground window, get it's HWND, and call DestroyWindow() on it. If it's a window from another application, you'll have to use something like GetForegroundWindow

Share this post


Link to post
Share on other sites

Hi,

thanks for the reply.

Will GetForegroundWindow work on windows that the app didn't create (ie, another app)? will it close the foreground app?

thanks.

Share this post


Link to post
Share on other sites
The window doesn't have to be created by your application. It won't destroy the window, but DestroyWindow() will.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!