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. set icon for a CButton

set icon for a CButton

Scheduled Pinned Locked Moved C / C++ / MFC
c++
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.
  • V Offline
    V Offline
    venadder
    wrote on last edited by
    #1

    hi, how will you display an icon on a button(CButton MFC VS2005 ), the icon is in say a fil c:\something.ico

    N H 2 Replies Last reply
    0
    • V venadder

      hi, how will you display an icon on a button(CButton MFC VS2005 ), the icon is in say a fil c:\something.ico

      N Offline
      N Offline
      Naveen
      wrote on last edited by
      #2

      First u have to load the icon using LoadImage() function.. then u will get a handle(HICON) for the icon. Now Pass this handle in the SetIcon function of the CButton nave

      1 Reply Last reply
      0
      • V venadder

        hi, how will you display an icon on a button(CButton MFC VS2005 ), the icon is in say a fil c:\something.ico

        H Offline
        H Offline
        Hamid Taebi
        wrote on last edited by
        #3

        HICON hicon=(HICON)LoadImage( AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDR_AnswerTYPE),IMAGE_ICON, 48, 48, LR_DEFAULTSIZE); m_Button1.SetIcon(hicon); and you need to set icon in property window from your button to true.

        V 1 Reply Last reply
        0
        • H Hamid Taebi

          HICON hicon=(HICON)LoadImage( AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDR_AnswerTYPE),IMAGE_ICON, 48, 48, LR_DEFAULTSIZE); m_Button1.SetIcon(hicon); and you need to set icon in property window from your button to true.

          V Offline
          V Offline
          venadder
          wrote on last edited by
          #4

          thankx a lot guys. Problem solved. Appreciate the help

          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