职业IT人-IT人生活圈

 找回密码
 成为会员
搜索
查看: 794|回复: 0

CMFCButton::SetImage MFC按钮

[复制链接]
爱车车 发表于 2011-9-26 10:29 | 显示全部楼层 |阅读模式
摘要:关于CMFCButton::SetImage MFC按钮的深入研究。
d041a4a1924323dc4710648e.jpg
  1.   //Windows logo 图标 放到按钮上
  2.   HICON hIconWinlogo= ::LoadIcon(AfxGetApp()->m_hInstance,(LPCTSTR)IDI_ICON1);
  3.   //Home图标
  4.   // HICON hIconHome= ::LoadIcon(AfxGetApp()->m_hInstance,(LPCTSTR)IDI_HOME);
  5.   //关闭图标
  6.   HICON hIconClose = ::LoadIcon(AfxGetApp()->m_hInstance,(LPCTSTR)IDI_RED_CLOSE_BOX);
  7.   ((CMFCButton *)GetDlgItem(IDC_BTN_CALC1) )->SetImage ( hIconWinlogo ); //"计算"按钮
  8.   ( (CMFCButton *)GetDlgItem(IDC_BTN_CALC2) )->SetImage ( hIconWinlogo ); //"计算"按钮
  9.   ( (CMFCButton *)GetDlgItem(IDC_BTN_CALC3) )->SetImage ( hIconWinlogo ); //"计算"按钮
  10.   ( (CMFCButton *)GetDlgItem(IDC_BTN_CALC4) )->SetImage ( hIconWinlogo ); //"计算"按钮
  11.   ( (CMFCButton *)GetDlgItem(IDCANCEL) )->SetImage ( hIconClose ); //退出
  12.   CMFCButton::SetImage
  13.   Sets the image for a button.
  14.   Copyvoid SetImage(
  15.   HICON hIcon,
  16.   BOOL bAutoDestroy=TRUE,
  17.   HICON hIconHot=NULL,
  18.   HICON hIconDisabled=NULL,
  19.   BOOL bAlphaBlend=FALSE
  20.   );
  21.   void SetImage(
  22.   HBITMAP hBitmap,
  23.   BOOL bAutoDestroy=TRUE,
  24.   HBITMAP hBitmapHot=NULL,
  25.   BOOL bMap3dColors=TRUE,
  26.   HBITMAP hBitmapDisabled=NULL
  27.   );
  28.   void SetImage(
  29.   UINT uiBmpResId,
  30.   UINT uiBmpHotResId=0,
  31.   UINT uiBmpDsblResID=0
  32.   );
  33.   Parameters
  34.      [in] hIcon
  35.   Handle to the icon that contains the bitmap and mask for the new image.
  36.   [in] bAutoDestroy
  37.   TRUE to specify that bitmap resources be destroyed automatically; otherwise, FALSE. The default is TRUE.
  38.   [in] hIconHot
  39.   Handle to the icon that contains the image for the selected state.
  40.   [in] hBitmap
  41.   Handle to the bitmap that contains the image for the non-selected state.
  42.   [in] hBitmapHot
  43.   Handle to the bitmap that contains the image for the selected state.
  44.   [in] uiBmpResId
  45.   Resource ID for the non-selected image.
  46.   [in] uiBmpHotResId
  47.   Resource ID for the selected image.
  48.   [in] bMap3dColors
  49.   Specifies a transparent color for the button background; that is, the face of the button. TRUE to use the color value RGB(192, 192, 192); FALSE to use the color value defined by AFX_GLOBAL_DATA::clrBtnFace.
  50.   [in] hIconDisabled
  51.   Handle to the icon for the disabled image.
  52.   [in] hBitmapDisabled
  53.   Handle to the bitmap that contains the disabled image.
  54.   [in] uiBmpDsblResID
  55.   Resource ID of the disabled bitmap.
  56.   [in] bAlphaBlend
  57.   TRUE to use only 32-bit images that use the alpha channel; FALSE, to not use only alpha channel images. The default is FALSE.
  58.   Example
  59.      The following example demonstrates how to use various versions of the SetImage method in the CMFCButton class. The example is part of the NewControls Sample: MFC Controls Demonstration Application.
  60.   VBC#C++F#JScriptCopyCMFCButton m_Button;
  61.   ...
  62.   // int m_iImage
  63.   // IDB_BTN1_32, IDB_BTN1_HOT_32, IDB_BTN1, IDB_BTN1_HOT are int macros that are #define.
  64.   if (m_iImage == 1)
  65.   {
  66.   m_Button.SetImage((HBITMAP) NULL);
  67.   }
复制代码
  else
  {
  m_Button.SetImage(IDB_BTN1_32, IDB_BTN1_HOT_32);
  }
您需要登录后才可以回帖 登录 | 成为会员

本版积分规则

QQ|手机版|小黑屋|网站帮助|职业IT人-IT人生活圈 ( 粤ICP备12053935号-1 )|网站地图
本站文章版权归原发布者及原出处所有。内容为作者个人观点,并不代表本站赞同其观点和对其真实性负责,本站只提供参考并不构成任何投资及应用建议。本站是信息平台,网站上部分文章为转载,并不用于任何商业目的,我们已经尽可能的对作者和来源进行了通告,但是能力有限或疏忽造成漏登,请及时联系我们,我们将根据著作权人的要求立即更正或者删除有关内容。

GMT+8, 2024-4-27 05:51 , Processed in 0.139442 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表