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. C / C++ / MFC
  4. Getting the dekstop window handle

Getting the dekstop window handle

Scheduled Pinned Locked Moved C / C++ / MFC
question
8 Posts 4 Posters 1 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.
  • S Offline
    S Offline
    SujayG
    wrote on last edited by
    #1

    How do I get the handle to the Windows desktop I dont think GetDesktopWindow returns the handle to the Windows desktop Thanks Sujay

    N CPalliniC 2 Replies Last reply
    0
    • S SujayG

      How do I get the handle to the Windows desktop I dont think GetDesktopWindow returns the handle to the Windows desktop Thanks Sujay

      N Offline
      N Offline
      Nuri Ismail
      wrote on last edited by
      #2

      sujayg wrote:

      I dont think GetDesktopWindow returns the handle to the Windows desktop

      Documentation says that it does. [^] Nuri Ismail

      1 Reply Last reply
      0
      • S SujayG

        How do I get the handle to the Windows desktop I dont think GetDesktopWindow returns the handle to the Windows desktop Thanks Sujay

        CPalliniC Offline
        CPalliniC Offline
        CPallini
        wrote on last edited by
        #3

        sujayg wrote:

        dont think GetDesktopWindow returns the handle to the Windows desktop

        MSDN [^]:

        The GetDesktopWindow function returns a handle to the desktop window.

        I see a conflict... :rolleyes:

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
        [My articles]

        In testa che avete, signor di Ceprano?

        S 1 Reply Last reply
        0
        • CPalliniC CPallini

          sujayg wrote:

          dont think GetDesktopWindow returns the handle to the Windows desktop

          MSDN [^]:

          The GetDesktopWindow function returns a handle to the desktop window.

          I see a conflict... :rolleyes:

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          S Offline
          S Offline
          SujayG
          wrote on last edited by
          #4

          Hello Ian, Yes the name is a bit confusing. The desktop handle is the main WIndow on top of which all Windows are painted . But it does not return the handle of the Window ( SysListView32 ) - which is the WIndows desktop . This can be checked with Spy++ There is another function, GetShellWindow, which "probably" returns the Windows desktop handle, I am testing that Sujay

          C 1 Reply Last reply
          0
          • S SujayG

            Hello Ian, Yes the name is a bit confusing. The desktop handle is the main WIndow on top of which all Windows are painted . But it does not return the handle of the Window ( SysListView32 ) - which is the WIndows desktop . This can be checked with Spy++ There is another function, GetShellWindow, which "probably" returns the Windows desktop handle, I am testing that Sujay

            C Offline
            C Offline
            Chris Losinger
            wrote on last edited by
            #5

            sujayg wrote:

            But it does not return the handle of the Window ( SysListView32 )

            that list view is not the desktop window, it is a child of a child of the desktop. you can verify that with Spy++ by looking at the ID of the Desktop window as shown in the default window list compared to the ID of that list view. the listview is a child of the Program Manager, which is the Windows Shell.

            image processing toolkits | batch image processing

            S 1 Reply Last reply
            0
            • C Chris Losinger

              sujayg wrote:

              But it does not return the handle of the Window ( SysListView32 )

              that list view is not the desktop window, it is a child of a child of the desktop. you can verify that with Spy++ by looking at the ID of the Desktop window as shown in the default window list compared to the ID of that list view. the listview is a child of the Program Manager, which is the Windows Shell.

              image processing toolkits | batch image processing

              S Offline
              S Offline
              SujayG
              wrote on last edited by
              #6

              Any idea how can I get the handle to that I guess I need to use FindWindow or FindWinodwEx, but on what. If you can help me with the code or at least the logic, I can try

              C N 2 Replies Last reply
              0
              • S SujayG

                Any idea how can I get the handle to that I guess I need to use FindWindow or FindWinodwEx, but on what. If you can help me with the code or at least the logic, I can try

                C Offline
                C Offline
                Chris Losinger
                wrote on last edited by
                #7

                use FindWindow to find "Program Manager", then use EnumChildWindows on its children. or, the long way... get the desktop window, then use EnumChildWindows to find the listview. note that EnumChildWindows is recursive, so it will do a search of every window in the system if you start at the desktop. but, just look for a window of the SysListView32 type whose parent is the "Program Manager".

                image processing toolkits | batch image processing

                1 Reply Last reply
                0
                • S SujayG

                  Any idea how can I get the handle to that I guess I need to use FindWindow or FindWinodwEx, but on what. If you can help me with the code or at least the logic, I can try

                  N Offline
                  N Offline
                  Nuri Ismail
                  wrote on last edited by
                  #8

                  Try this:

                  HWND hProgMan = FindWindow("Progman", NULL);
                  HWND hDefView = FindWindowEx(hProgMan, NULL, "SHELLDLL_DefView", NULL);
                  HWND hSysListView = FindWindowEx(hDefView, NULL, "SysListView32", NULL);

                  Nuri Ismail

                  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