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. Why doesn't CStatic keep the size of the icon when using SetIcon?

Why doesn't CStatic keep the size of the icon when using SetIcon?

Scheduled Pinned Locked Moved C / C++ / MFC
question
4 Posts 3 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Hi! I have a very simple class used to display a checkbox, filled or not depending on if a task is finished. I the dialog editor, I set the SS_REALSIZEIMAGE property. This works great, until the image is set using SetIcon. After that call, CStatic formats the icon as a 32x32, which I don't like. I've tried to use ModifyStyle and RedrawWindow after the call to SetIcon, but no success. My code: void CTaskFinishedCheck::SetFinished(BOOL bFinished) { if ( bFinished ) { SetIcon( hCheckedIcon ); } else { SetIcon( hUncheckedIcon ); } } Someone who knows?

    P 1 Reply Last reply
    0
    • L Lost User

      Hi! I have a very simple class used to display a checkbox, filled or not depending on if a task is finished. I the dialog editor, I set the SS_REALSIZEIMAGE property. This works great, until the image is set using SetIcon. After that call, CStatic formats the icon as a 32x32, which I don't like. I've tried to use ModifyStyle and RedrawWindow after the call to SetIcon, but no success. My code: void CTaskFinishedCheck::SetFinished(BOOL bFinished) { if ( bFinished ) { SetIcon( hCheckedIcon ); } else { SetIcon( hUncheckedIcon ); } } Someone who knows?

      P Offline
      P Offline
      Peter Godec
      wrote on last edited by
      #2

      Hi! Use the ::LoadImage API function instead of CWinApp::LoadIcon(). For example:

      HINSTANCE hInst = AfxGetInstanceHandle();
      hIcon = (HICON) ::LoadImage(hInst, MAKEINTRESOURCE(IDI_FOOBAR), IMAGE_ICON, 16, 16, 0);

      Hope this helps!

      L G 2 Replies Last reply
      0
      • P Peter Godec

        Hi! Use the ::LoadImage API function instead of CWinApp::LoadIcon(). For example:

        HINSTANCE hInst = AfxGetInstanceHandle();
        hIcon = (HICON) ::LoadImage(hInst, MAKEINTRESOURCE(IDI_FOOBAR), IMAGE_ICON, 16, 16, 0);

        Hope this helps!

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

        It did. Thanks. I must learn to read the whole Remark section.

        1 Reply Last reply
        0
        • P Peter Godec

          Hi! Use the ::LoadImage API function instead of CWinApp::LoadIcon(). For example:

          HINSTANCE hInst = AfxGetInstanceHandle();
          hIcon = (HICON) ::LoadImage(hInst, MAKEINTRESOURCE(IDI_FOOBAR), IMAGE_ICON, 16, 16, 0);

          Hope this helps!

          G Offline
          G Offline
          Gast128
          wrote on last edited by
          #4

          Thx, I experienced the same problem using CStatic::SetIcon with dynamically loaded icon thru LoadIcon. The LoadIcon function seems to scale down any icon dimension back to system defaults (e.g. (32, 32)).

          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