Get a collection of handles to all the open window
-
I already know how to get the handle to the foreground window using the GetForegroundWindow() function inside user32.dll, but i also need something that will return a collection of the handles of all the open windows. If there is no function to do this, and you think there could be another way to do this, please let me know.
-
I already know how to get the handle to the foreground window using the GetForegroundWindow() function inside user32.dll, but i also need something that will return a collection of the handles of all the open windows. If there is no function to do this, and you think there could be another way to do this, please let me know.
Hi, user32.dll also holds EnumChildWindows and EnumWindows for you. :)
Luc Pattyn [Forum Guidelines] [My Articles]
Voting for dummies? No thanks. X|
-
I already know how to get the handle to the foreground window using the GetForegroundWindow() function inside user32.dll, but i also need something that will return a collection of the handles of all the open windows. If there is no function to do this, and you think there could be another way to do this, please let me know.
Thanks. I tried that, and for some reason i get 537 handles returned. Obviously, i don't have 537 windows open, so would you (or anyone else) happen to know why it enumerates that many times??? Also, to make myself more clear, i am making a virtual desktop program, so i only want to get the windows that are actually visible (excluding the explorer.exe process).
modified on Monday, July 7, 2008 12:13 AM
-
Thanks. I tried that, and for some reason i get 537 handles returned. Obviously, i don't have 537 windows open, so would you (or anyone else) happen to know why it enumerates that many times??? Also, to make myself more clear, i am making a virtual desktop program, so i only want to get the windows that are actually visible (excluding the explorer.exe process).
modified on Monday, July 7, 2008 12:13 AM
Every control is it's own window, visible or not. Even controls that you think are a single control, are really a combination of smaller controls working together.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008 -
I already know how to get the handle to the foreground window using the GetForegroundWindow() function inside user32.dll, but i also need something that will return a collection of the handles of all the open windows. If there is no function to do this, and you think there could be another way to do this, please let me know.
I managed to narrow it down to filter out everything but the open windows using the IsWindow() and IsWindowVisible() function inside user32.
-
Thanks. I tried that, and for some reason i get 537 handles returned. Obviously, i don't have 537 windows open, so would you (or anyone else) happen to know why it enumerates that many times??? Also, to make myself more clear, i am making a virtual desktop program, so i only want to get the windows that are actually visible (excluding the explorer.exe process).
modified on Monday, July 7, 2008 12:13 AM
Actually you do have 537 window handles open at one time. To see details on the windows (or for that matter actually believe you have 537 windows open), you can open Spy++ which is an application installed by Visual Studio for debugging aspects of programs and the OS. Spy++, which should be able to be found in the start menu and will list every window/sub-window currently displayed in windows.
Regards, Thomas Stockwell Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Visit my homepage Oracle Studios Discounted or Free Software for Students: DreamSpark - downloads.channel8.msdn.com MSDN Academic Alliance - www.msdnaa.com