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 type of Icon in system messages

How to get type of Icon in system messages

Scheduled Pinned Locked Moved C / C++ / MFC
helpsecuritytutorialquestion
5 Posts 3 Posters 2 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.
  • U Offline
    U Offline
    User 10847587
    wrote on last edited by
    #1

    Hi, I writing a small application which will notify whenever any windows messages or Dialogue boxes appear with any of the (Error,Information,Warning,Question) Icons. this is how i am doing.. main() { WinHAn = FindWindowA(NULL,"Windows Security"); if(WinHAn != NULL) { EnumChildWindows(WinHAn,SearchIcon,(LPARAM) &winIconSearch); } } static BOOL CALLBACK SearchIcon(HWND hwnd, LPARAM lParam) { style = GetWindowLongPtr(hwnd, GWL_STYLE); if ((style & SS_ICON) == SS_ICON) { thisHan =(UINT64)SendMessageW(hwnd, STM_GETIMAGE,IMAGE_ICON, 0L); searchHan =(UINT64) LoadIconA(NULL, (LPCSTR)(IDI_WARNING)); if(thisHan ==searchHan ) { printf("Icon Found"); } return TRUE; } This is only for Warning messages.But it is not working. can any body tell me what the problem is.. Thanks. vvk.

    J L 2 Replies Last reply
    0
    • U User 10847587

      Hi, I writing a small application which will notify whenever any windows messages or Dialogue boxes appear with any of the (Error,Information,Warning,Question) Icons. this is how i am doing.. main() { WinHAn = FindWindowA(NULL,"Windows Security"); if(WinHAn != NULL) { EnumChildWindows(WinHAn,SearchIcon,(LPARAM) &winIconSearch); } } static BOOL CALLBACK SearchIcon(HWND hwnd, LPARAM lParam) { style = GetWindowLongPtr(hwnd, GWL_STYLE); if ((style & SS_ICON) == SS_ICON) { thisHan =(UINT64)SendMessageW(hwnd, STM_GETIMAGE,IMAGE_ICON, 0L); searchHan =(UINT64) LoadIconA(NULL, (LPCSTR)(IDI_WARNING)); if(thisHan ==searchHan ) { printf("Icon Found"); } return TRUE; } This is only for Warning messages.But it is not working. can any body tell me what the problem is.. Thanks. vvk.

      J Offline
      J Offline
      Jochen Arndt
      wrote on last edited by
      #2

      You might add some more output to your program to see which code is reached or use the debugger for the same purpose. E.g. if a window with the title "Windows Security" is found and if such a window contains a static control with an icon. Your check for SS_ICON is wrong (but this is not the reason for finding nothing). You should use:

      if ((style & SS_TYPEMASK) == SS_ICON)

      Finally I'm not sure if this can be done this way. While the LoadIcon description states that it may return a handle to an existing resource, this may be only true when the icon has been loaded by the same application.

      1 Reply Last reply
      0
      • U User 10847587

        Hi, I writing a small application which will notify whenever any windows messages or Dialogue boxes appear with any of the (Error,Information,Warning,Question) Icons. this is how i am doing.. main() { WinHAn = FindWindowA(NULL,"Windows Security"); if(WinHAn != NULL) { EnumChildWindows(WinHAn,SearchIcon,(LPARAM) &winIconSearch); } } static BOOL CALLBACK SearchIcon(HWND hwnd, LPARAM lParam) { style = GetWindowLongPtr(hwnd, GWL_STYLE); if ((style & SS_ICON) == SS_ICON) { thisHan =(UINT64)SendMessageW(hwnd, STM_GETIMAGE,IMAGE_ICON, 0L); searchHan =(UINT64) LoadIconA(NULL, (LPCSTR)(IDI_WARNING)); if(thisHan ==searchHan ) { printf("Icon Found"); } return TRUE; } This is only for Warning messages.But it is not working. can any body tell me what the problem is.. Thanks. vvk.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Stepping through your code with the debugger will identify where it is failing. Have you checked that there is a currently open Window with the title "Windows Security", to satisfy the FindWindowA call? By the way, it is really bad practice to use the A or W suffixes on your Windows API calls. Use the project settings to set your project to ASCII or Unicode mode, and let the compiler generate the appropriate code.

        U 1 Reply Last reply
        0
        • L Lost User

          Stepping through your code with the debugger will identify where it is failing. Have you checked that there is a currently open Window with the title "Windows Security", to satisfy the FindWindowA call? By the way, it is really bad practice to use the A or W suffixes on your Windows API calls. Use the project settings to set your project to ASCII or Unicode mode, and let the compiler generate the appropriate code.

          U Offline
          U Offline
          User 10847587
          wrote on last edited by
          #4

          Hi, i have tried with debugging and the it is failing at the if condition if(thisHan ==searchHan).Sendmessage function('thisHan') is returnig one value and where Loadicon function is returning('searchHan') different value.

          L 1 Reply Last reply
          0
          • U User 10847587

            Hi, i have tried with debugging and the it is failing at the if condition if(thisHan ==searchHan).Sendmessage function('thisHan') is returnig one value and where Loadicon function is returning('searchHan') different value.

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            So the icons don't match. All that tells you is that the icon for the message window is not the one you were hoping for. The chances of you being able to use this code in a production environment are not very high, since very few applications will be doing things the way you expect or want.

            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