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. Adding CStatic Icon to a dialog box

Adding CStatic Icon to a dialog box

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

    I am trying to add a CStatic item in the form of an icon to a dialog box and I am having no luck... I have added this code to the OnInitDialog section: CStatic myStatic; myStatic.Create(_T("my static"), WS_CHILD|WS_VISIBLE|SS_ICON|SS_CENTERIMAGE, CRect(10,10,150,50), this); myStatic.SetIcon( ::LoadIcon(NULL, IDI_QUESTION) ); Is there anything wrong that I am doing?

    J 1 Reply Last reply
    0
    • L Lost User

      I am trying to add a CStatic item in the form of an icon to a dialog box and I am having no luck... I have added this code to the OnInitDialog section: CStatic myStatic; myStatic.Create(_T("my static"), WS_CHILD|WS_VISIBLE|SS_ICON|SS_CENTERIMAGE, CRect(10,10,150,50), this); myStatic.SetIcon( ::LoadIcon(NULL, IDI_QUESTION) ); Is there anything wrong that I am doing?

      J Offline
      J Offline
      JerzyPeter
      wrote on last edited by
      #2

      You can do that this way: 1. Insert a picture control on your Dialog. 2. In properties of this control enter Type: Icon and Image: IDI_QUESTION. Jerzy

      L 1 Reply Last reply
      0
      • J JerzyPeter

        You can do that this way: 1. Insert a picture control on your Dialog. 2. In properties of this control enter Type: Icon and Image: IDI_QUESTION. Jerzy

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

        but if I want to do it on the run?

        J 1 Reply Last reply
        0
        • L Lost User

          but if I want to do it on the run?

          J Offline
          J Offline
          JerzyPeter
          wrote on last edited by
          #4

          Add CStatic myStatic in your class. In OnInitDialog(): myStatic.Create(_T("my static"), WS_CHILD|WS_VISIBLE|SS_ICON|SS_CENTERIMAGE, CRect(10,10,150,50), this); myStatic.SetIcon(::LoadIcon(::AfxGetInstanceHandle(),MAKEINTRESOURCE(IDI_QUESTION)));

          L 1 Reply Last reply
          0
          • J JerzyPeter

            Add CStatic myStatic in your class. In OnInitDialog(): myStatic.Create(_T("my static"), WS_CHILD|WS_VISIBLE|SS_ICON|SS_CENTERIMAGE, CRect(10,10,150,50), this); myStatic.SetIcon(::LoadIcon(::AfxGetInstanceHandle(),MAKEINTRESOURCE(IDI_QUESTION)));

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

            And one more question... I am trying to use icon 161 in shell32.dll... The default Icon in the file actually has a green background, but typically this background is not shown in Windows dialogs. How do you make the background match the background of the dialog while the rest of items retain their original color?

            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