HOW TO LOAD AN ICON ON A CBUTTON AT RUNTIME?

Dependra Pathak

Total Post:77

Points:385
Posted by  Dependra Pathak
 1700  View(s)
Ratings:
Rate this:
  1. Dependra Pathak

    Post:77

    Points:385
    How to load an Icon on a CButton at Runtime?

    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
    btnsample->SetIcon(hIcon);

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!