Home > DeveloperSection > Interviews > How to load an Icon on a CButton at Runtime?

Posted on    March-28-2011 8:36 AM

 Visual C++ Visual C++ 
 1 Answer(s)
  1651  View(s)
Rate this:

Dependra Pathak
Dependra Pathak

Total Post:77

Posted on    March-28-2011 12:00 AM

CButton *btnsample = (CButton *)GetDlgItem(IDC_BUTTON1);
btnsample->ModifyStyle(0,BS_ICON,SWP_FRAMECHANGED); //change the style of CButton
HICON hIcon = ::LoadIcon(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDI_ICON)); //load an Icon assuming IDI_ICON is ID of ICON

Don't want to miss updates? Please click the below button!

Follow MindStick