Sign in to follow this  
_nomad_

[WIN32 API] Getting Window ID

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this