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. Icon not showing in CStatic Control

Icon not showing in CStatic Control

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
4 Posts 3 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.
  • T Offline
    T Offline
    Tom Moore
    wrote on last edited by
    #1

    Hi, I am programming a custom error dialog box with two three CStatic Controls. The first is a title, the second is a message and the third is a picture box set to be a icon. The first two are okay. The third is really bugging me! I've created a variable for the CStatic from the Variable Wizard called m_Icon and then in Init_Dialg I set it to a standard Icon using this: m_Icon.SetIcon(AfxGetApp()->LoadStandardIcon(IDI_EXCLAMATION)); I have also tried creating an Icon using HICON and setting the control to the HICON and using the method m_Icon.SetIcon(::LoadIcon(IDI_EXCLAMATION)); They all compile fine. But when i the app runs, i dont see the Icon. The Controls Visability is set to TRUE. Where have I gone wrong and how can I correct this? Many Thanks Tom. P.S Personally creating Custom Error Dialogs is a pain, and I am looking forward to seeing the Windows Vista TaskDialog!! :cool: ;) -- modified at 16:09 Sunday 22nd January, 2006

    P R 2 Replies Last reply
    0
    • T Tom Moore

      Hi, I am programming a custom error dialog box with two three CStatic Controls. The first is a title, the second is a message and the third is a picture box set to be a icon. The first two are okay. The third is really bugging me! I've created a variable for the CStatic from the Variable Wizard called m_Icon and then in Init_Dialg I set it to a standard Icon using this: m_Icon.SetIcon(AfxGetApp()->LoadStandardIcon(IDI_EXCLAMATION)); I have also tried creating an Icon using HICON and setting the control to the HICON and using the method m_Icon.SetIcon(::LoadIcon(IDI_EXCLAMATION)); They all compile fine. But when i the app runs, i dont see the Icon. The Controls Visability is set to TRUE. Where have I gone wrong and how can I correct this? Many Thanks Tom. P.S Personally creating Custom Error Dialogs is a pain, and I am looking forward to seeing the Windows Vista TaskDialog!! :cool: ;) -- modified at 16:09 Sunday 22nd January, 2006

      P Offline
      P Offline
      PJ Arends
      wrote on last edited by
      #2

      LoadStandardIcon() takes a LPCTSTR, not an UINT. Use the MAKEINTRESOURCE macro to convert IDI_EXCLAMATION to an LPCTSTR.

      m_Icon.SetIcon(AfxGetApp()->LoadStandardIcon(MAKEINTRESOURCE(IDI_EXCLAMATION));

      ::LoadIcon takes two parameters, the first of which is the handle to the applications's instance, or NULL if loading standard icons. I am surprised the code even compiled.


      "You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ???  You're definitely a superstar!!!" - mYkel - 21 Jun '04 "There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05 Within you lies the power for good - Use it!

      R 1 Reply Last reply
      0
      • P PJ Arends

        LoadStandardIcon() takes a LPCTSTR, not an UINT. Use the MAKEINTRESOURCE macro to convert IDI_EXCLAMATION to an LPCTSTR.

        m_Icon.SetIcon(AfxGetApp()->LoadStandardIcon(MAKEINTRESOURCE(IDI_EXCLAMATION));

        ::LoadIcon takes two parameters, the first of which is the handle to the applications's instance, or NULL if loading standard icons. I am surprised the code even compiled.


        "You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ???  You're definitely a superstar!!!" - mYkel - 21 Jun '04 "There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05 Within you lies the power for good - Use it!

        R Offline
        R Offline
        Ryan Binns
        wrote on last edited by
        #3

        Actually, IDI_EXCLAMATION is defined in winuser.h using MAKEINTRESOURCE(), so it's not needed here.

        Ryan

        "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

        1 Reply Last reply
        0
        • T Tom Moore

          Hi, I am programming a custom error dialog box with two three CStatic Controls. The first is a title, the second is a message and the third is a picture box set to be a icon. The first two are okay. The third is really bugging me! I've created a variable for the CStatic from the Variable Wizard called m_Icon and then in Init_Dialg I set it to a standard Icon using this: m_Icon.SetIcon(AfxGetApp()->LoadStandardIcon(IDI_EXCLAMATION)); I have also tried creating an Icon using HICON and setting the control to the HICON and using the method m_Icon.SetIcon(::LoadIcon(IDI_EXCLAMATION)); They all compile fine. But when i the app runs, i dont see the Icon. The Controls Visability is set to TRUE. Where have I gone wrong and how can I correct this? Many Thanks Tom. P.S Personally creating Custom Error Dialogs is a pain, and I am looking forward to seeing the Windows Vista TaskDialog!! :cool: ;) -- modified at 16:09 Sunday 22nd January, 2006

          R Offline
          R Offline
          Ryan Binns
          wrote on last edited by
          #4

          Does your static control have the SS_ICON style set?

          Ryan

          "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

          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