How to set an image to a button in a ribbon using MFC VC++ ?

  • Thread starter Thread starter Najat Ismail
  • Start date Start date
N

Najat Ismail

Guest
I am changing the look of my CMFCRibbonBar. I want to add icon to its button, so i added my png images as resources and gave them IDs, but i can't seem to connect them to buttons.

I added this code to my CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) function:

CButton *pButton = (CButton *)GetDlgItem(m_Print);
if (pButton && pButton->GetSafeHwnd())
{
pButton->SetIcon((HICON)LoadImage(AfxGetApp()->m_hInstance,
MAKEINTRESOURCE(IDB_Print),
IMAGE_ICON, 32, 32, LR_DEFAULTCOLOR));
}
pButton = (CButton *)GetDlgItem(m_SaveSett);
if (pButton && pButton->GetSafeHwnd())
{
pButton->SetIcon((HICON)LoadImage(AfxGetApp()->m_hInstance,
MAKEINTRESOURCE(IDB_SaveSettings),
IMAGE_BITMAP, 32, 32, LR_COLOR));
}

Continue reading...
 
Back
Top