Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Get a collection of handles to all the open window

Get a collection of handles to all the open window

Scheduled Pinned Locked Moved Visual Basic
tutorial
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jacobjordan
    wrote on last edited by
    #1

    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.

    L J 3 Replies Last reply
    0
    • J jacobjordan

      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.

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, user32.dll also holds EnumChildWindows and EnumWindows for you. :)

      Luc Pattyn [Forum Guidelines] [My Articles]


      Voting for dummies? No thanks. X|


      1 Reply Last reply
      0
      • J jacobjordan

        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.

        J Offline
        J Offline
        jacobjordan
        wrote on last edited by
        #3

        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

        D T 2 Replies Last reply
        0
        • J jacobjordan

          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

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          • J jacobjordan

            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.

            J Offline
            J Offline
            jacobjordan
            wrote on last edited by
            #5

            I managed to narrow it down to filter out everything but the open windows using the IsWindow() and IsWindowVisible() function inside user32.

            1 Reply Last reply
            0
            • J jacobjordan

              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

              T Offline
              T Offline
              Thomas Stockwell
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups