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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to get icons of all opened windows?

How to get icons of all opened windows?

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
4 Posts 2 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.
  • A Offline
    A Offline
    Artem Moroz
    wrote on last edited by
    #1

    How to get icons of all currently opened windows(top-level, unowned) ?

    D 1 Reply Last reply
    0
    • A Artem Moroz

      How to get icons of all currently opened windows(top-level, unowned) ?

      D Offline
      D Offline
      dabs
      wrote on last edited by
      #2

      You would enumerate all top level windows using ::EnumWindows( ) and given a handle to a window you can send it a WM_GETICON message.


      Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!

      A 1 Reply Last reply
      0
      • D dabs

        You would enumerate all top level windows using ::EnumWindows( ) and given a handle to a window you can send it a WM_GETICON message.


        Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!

        A Offline
        A Offline
        Artem Moroz
        wrote on last edited by
        #3

        This is my code HICON NewGetIcon(HWND p_hWnd) { HICON hIcon = NULL; HMODULE hInst = (HMODULE)GetClassLong(p_hWnd,GWL_HINSTANCE); hIcon = (HICON)::SendMessage(p_hWnd,WM_GETICON,ICON_SMALL,0); /* if (hIcon == NULL) { CString strFile; int RtnLength = GetModuleFileName(hInst, strFile.GetBuffer(256), 255); WORD wIcon = 0; hIcon = ExtractAssociatedIcon(AfxGetApp()->m_hInstance,strFile.GetBuffer(0),&wIcon); }*/ // if (hIcon == NULL) // hIcon = (HICON)::SendMessage(p_hWnd,WM_GETICON,ICON_BIG,0); if (hIcon == NULL) hIcon = (HICON)GetClassLong(p_hWnd,GCL_HICONSM); if (hIcon == NULL) hIcon = (HICON)GetClassLong(p_hWnd,GCL_HICON); // if(hIcon != NULL) // DuplicateIcon(hInst,hIcon); return (hIcon); } The problem is that it returns either not correct icon or empty icon (not NULL!) Of course, I've different combiantions of commenting, uncommneting...

        D 1 Reply Last reply
        0
        • A Artem Moroz

          This is my code HICON NewGetIcon(HWND p_hWnd) { HICON hIcon = NULL; HMODULE hInst = (HMODULE)GetClassLong(p_hWnd,GWL_HINSTANCE); hIcon = (HICON)::SendMessage(p_hWnd,WM_GETICON,ICON_SMALL,0); /* if (hIcon == NULL) { CString strFile; int RtnLength = GetModuleFileName(hInst, strFile.GetBuffer(256), 255); WORD wIcon = 0; hIcon = ExtractAssociatedIcon(AfxGetApp()->m_hInstance,strFile.GetBuffer(0),&wIcon); }*/ // if (hIcon == NULL) // hIcon = (HICON)::SendMessage(p_hWnd,WM_GETICON,ICON_BIG,0); if (hIcon == NULL) hIcon = (HICON)GetClassLong(p_hWnd,GCL_HICONSM); if (hIcon == NULL) hIcon = (HICON)GetClassLong(p_hWnd,GCL_HICON); // if(hIcon != NULL) // DuplicateIcon(hInst,hIcon); return (hIcon); } The problem is that it returns either not correct icon or empty icon (not NULL!) Of course, I've different combiantions of commenting, uncommneting...

          D Offline
          D Offline
          dabs
          wrote on last edited by
          #4

          Have you tried using CopyIcon( ) at the end of this functionÐ Check out http://www.cs.ucf.edu/~heimburg/wicon_FAQ.html[^]


          Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!

          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