how to add bitmap image to buttons in MFC?

前端 未结 6 2010
灰色年华
灰色年华 2020-12-10 16:29

I am Trying to add an image to an existing button..I have done that to an extent, the problem is I can add an ownerdrawn Image but am not able to add the extact image that I

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-10 17:20

    you don't know how much this helped out. Thanks for posting. Also have to change a few other things to bitmap as well ...

    CButton* pBtn= (CButton*)GetDlgItem(ID_MYDIALOG);
    pBtn->ModifyStyle( 0, BS_BITMAP );
    
    HBITMAP hIcn= (HBITMAP)LoadImage(
      AfxGetApp()->m_hInstance,
      MAKEINTRESOURCE(IDB_MYPIC),
      IMAGE_BITMAP,
      0,0, // use actual size
      LR_DEFAULTCOLOR
      );
    
    pBtn->SetBitmap( hIcn );
    

提交回复
热议问题