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. Button::SetIcon()

Button::SetIcon()

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
2 Posts 2 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.
  • R Offline
    R Offline
    Ruca
    wrote on last edited by
    #1

    Hi, I am using VC++ 7.0 and am trying to load an icon, which I have as one of my resources, into my button. The button is created dynamically. Here is the code that I have: button->Create("SMS", WS_CHILD | WS_VISIBLE | BS_FLAT | BS_ICON, CRect(0,0,0,0), &m_wndStatusBar, IDC_BUTTON_STATUS_BAR); button->SetIcon(::LoadIcon(NULL, MAKEINTRESOURCE(IDI_ICON1) ) ); This does not seem to work. I know it worked in VC++ 6.0. Can anyone help me out here? Thanking you in anticipation Rui

    A 1 Reply Last reply
    0
    • R Ruca

      Hi, I am using VC++ 7.0 and am trying to load an icon, which I have as one of my resources, into my button. The button is created dynamically. Here is the code that I have: button->Create("SMS", WS_CHILD | WS_VISIBLE | BS_FLAT | BS_ICON, CRect(0,0,0,0), &m_wndStatusBar, IDC_BUTTON_STATUS_BAR); button->SetIcon(::LoadIcon(NULL, MAKEINTRESOURCE(IDI_ICON1) ) ); This does not seem to work. I know it worked in VC++ 6.0. Can anyone help me out here? Thanking you in anticipation Rui

      A Offline
      A Offline
      alannx
      wrote on last edited by
      #2

      m_ctrlViewList.SetIcon(AfxGetApp()->LoadIcon(IDI_VIEW_LIST));

      :laugh: which m_ctrlViewList is a CButton, more...the icon size is in 32 pixel ================== BTW, if you want set a other size of icon, like 16*16 size, you can code like this.. //.h file CImageList m_ButtonImages; //.cpp file m_ButtonImages.Create(16,16,ILC_COLOR32 ,2,2); //create you icon list m_ButtonImages.Add(AfxGetApp()->LoadIcon(IDI_VIEW_ICON )); m_ButtonImages.Add(AfxGetApp()->LoadIcon(IDI_VIEW_LIST )); m_ctrlViewIcon.SetIcon( m_ButtonImages.ExtractIcon(0)); m_ctrlViewList.SetIcon(m_ButtonImages.ExtractIcon(1));

      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