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. obtaining app-icon of another process

obtaining app-icon of another process

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
8 Posts 5 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.
  • M Offline
    M Offline
    mightyCoCo
    wrote on last edited by
    #1

    hello, what i have is a list of all open windows and running processes. i have a hwnd to each window and its processid. all what i need - i thought. my problem is, i want to list all running tasks in a listbox and show each window´s icon in the listbox... but how to get the icon? i used attached the handle to the window with an CWnd and called hIcon = pWnd.GetIcon(true); - after that i detached that handle from the CWnd... but it only work at 2 apps ;o) so: how to get ann icon of another running process/window??? i searched the net all the night and didn´t found any interesting articles... cheers, vertex_x

    T T M 3 Replies Last reply
    0
    • M mightyCoCo

      hello, what i have is a list of all open windows and running processes. i have a hwnd to each window and its processid. all what i need - i thought. my problem is, i want to list all running tasks in a listbox and show each window´s icon in the listbox... but how to get the icon? i used attached the handle to the window with an CWnd and called hIcon = pWnd.GetIcon(true); - after that i detached that handle from the CWnd... but it only work at 2 apps ;o) so: how to get ann icon of another running process/window??? i searched the net all the night and didn´t found any interesting articles... cheers, vertex_x

      T Offline
      T Offline
      toxcct
      wrote on last edited by
      #2

      AfxGetInstance...()->LoadIcon() i don't remember exactly the fisrt function name, but it might be something like this...


      TOXCCT >>> GEII power
      [toxcct][VisualCalc]

      M 1 Reply Last reply
      0
      • T toxcct

        AfxGetInstance...()->LoadIcon() i don't remember exactly the fisrt function name, but it might be something like this...


        TOXCCT >>> GEII power
        [toxcct][VisualCalc]

        M Offline
        M Offline
        mightyCoCo
        wrote on last edited by
        #3

        you ment AfxGetApp()? that works only on your own created process as far as i know... i don´t know a way to do something linke CWnd::AfxGetApp()->... also ::AfxGetApp is no function in the global namespace... thanks 4 reading ;o) cheers, arné

        T 1 Reply Last reply
        0
        • M mightyCoCo

          you ment AfxGetApp()? that works only on your own created process as far as i know... i don´t know a way to do something linke CWnd::AfxGetApp()->... also ::AfxGetApp is no function in the global namespace... thanks 4 reading ;o) cheers, arné

          T Offline
          T Offline
          toxcct
          wrote on last edited by
          #4

          hum, yes your right... what about LoadModule() ? (or smthing similar ? :D )


          TOXCCT >>> GEII power
          [toxcct][VisualCalc]

          1 Reply Last reply
          0
          • M mightyCoCo

            hello, what i have is a list of all open windows and running processes. i have a hwnd to each window and its processid. all what i need - i thought. my problem is, i want to list all running tasks in a listbox and show each window´s icon in the listbox... but how to get the icon? i used attached the handle to the window with an CWnd and called hIcon = pWnd.GetIcon(true); - after that i detached that handle from the CWnd... but it only work at 2 apps ;o) so: how to get ann icon of another running process/window??? i searched the net all the night and didn´t found any interesting articles... cheers, vertex_x

            T Offline
            T Offline
            ThatsAlok
            wrote on last edited by
            #5

            Check out for this api [ExtractIcon]

            "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

            cheers, Alok Gupta

            1 Reply Last reply
            0
            • M mightyCoCo

              hello, what i have is a list of all open windows and running processes. i have a hwnd to each window and its processid. all what i need - i thought. my problem is, i want to list all running tasks in a listbox and show each window´s icon in the listbox... but how to get the icon? i used attached the handle to the window with an CWnd and called hIcon = pWnd.GetIcon(true); - after that i detached that handle from the CWnd... but it only work at 2 apps ;o) so: how to get ann icon of another running process/window??? i searched the net all the night and didn´t found any interesting articles... cheers, vertex_x

              M Offline
              M Offline
              mark novak
              wrote on last edited by
              #6

              I get nice results by using SendMessage with WM_GETICON. If that is invalid there is always GetClassLong with an index of GCL_HICON. HICON icon; icon = (HICON) ::SendMessage(hwnd, WM_GETICON, ICON_SMALL, 0); icon = (HICON) ::GetClassLong(hwnd, GCL_HICON);

              M 1 Reply Last reply
              0
              • M mark novak

                I get nice results by using SendMessage with WM_GETICON. If that is invalid there is always GetClassLong with an index of GCL_HICON. HICON icon; icon = (HICON) ::SendMessage(hwnd, WM_GETICON, ICON_SMALL, 0); icon = (HICON) ::GetClassLong(hwnd, GCL_HICON);

                M Offline
                M Offline
                mightyCoCo
                wrote on last edited by
                #7

                thats it! thanks a lot! :o) hIcon = (HICON)::SendMessage(hwnd, WM_GETICON, ICON_BIG, 0); if(hIcon == NULL) hIcon = (HICON)::GetClassLong(hwnd, GCL_HICON); if(hIcon == NULL) hIcon = (HICON)::GetClassLong(::GetParent(hwnd), GCL_HICON); works - no just looking when hIcon is still NULL, if there is a ICON_SMALL :o) cheers and thanx vertex_x

                S 1 Reply Last reply
                0
                • M mightyCoCo

                  thats it! thanks a lot! :o) hIcon = (HICON)::SendMessage(hwnd, WM_GETICON, ICON_BIG, 0); if(hIcon == NULL) hIcon = (HICON)::GetClassLong(hwnd, GCL_HICON); if(hIcon == NULL) hIcon = (HICON)::GetClassLong(::GetParent(hwnd), GCL_HICON); works - no just looking when hIcon is still NULL, if there is a ICON_SMALL :o) cheers and thanx vertex_x

                  S Offline
                  S Offline
                  saarfu
                  wrote on last edited by
                  #8

                  thanks friend this helped me too...

                  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