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