以文本方式查看主题

-  计算机科学论坛  (http://bbs.xml.org.cn/index.asp)
--  『 C/C++编程思想 』  (http://bbs.xml.org.cn/list.asp?boardid=61)
----  CMFCButton::SetImage  (http://bbs.xml.org.cn/dispbbs.asp?boardid=61&rootid=&id=87913)


--  作者:葛靖青001
--  发布时间:11/24/2010 3:19:00 PM

--  CMFCButton::SetImage
【转自互联网】

//Windows logo 图标 放到按钮上

  HICON hIconWinlogo= ::LoadIcon(AfxGetApp()->m_hInstance,(LPCTSTR)IDI_ICON1);

  //Home图标

  // HICON hIconHome= ::LoadIcon(AfxGetApp()->m_hInstance,(LPCTSTR)IDI_HOME);

  //关闭图标

  HICON hIconClose = ::LoadIcon(AfxGetApp()->m_hInstance,(LPCTSTR)IDI_RED_CLOSE_BOX);

  ((CMFCButton *)GetDlgItem(IDC_BTN_CALC1) )->SetImage ( hIconWinlogo ); //"计算"按钮

  ( (CMFCButton *)GetDlgItem(IDC_BTN_CALC2) )->SetImage ( hIconWinlogo ); //"计算"按钮

  ( (CMFCButton *)GetDlgItem(IDC_BTN_CALC3) )->SetImage ( hIconWinlogo ); //"计算"按钮

  ( (CMFCButton *)GetDlgItem(IDC_BTN_CALC4) )->SetImage ( hIconWinlogo ); //"计算"按钮

  ( (CMFCButton *)GetDlgItem(IDCANCEL)     )->SetImage ( hIconClose );   //退出

  CMFCButton::SetImage

  Sets the image for a button.

  Copyvoid SetImage(

  HICON hIcon,

  BOOL bAutoDestroy=TRUE,

  HICON hIconHot=NULL,

  HICON hIconDisabled=NULL,

  BOOL bAlphaBlend=FALSE

  );

  void SetImage(

  HBITMAP hBitmap,

  BOOL bAutoDestroy=TRUE,

  HBITMAP hBitmapHot=NULL,

  BOOL bMap3dColors=TRUE,

  HBITMAP hBitmapDisabled=NULL

  );

  void SetImage(

  UINT uiBmpResId,

  UINT uiBmpHotResId=0,

  UINT uiBmpDsblResID=0

  );

  Parameters

  --------------------------------------------------------------------------------

  [in] hIcon

  Handle to the icon that contains the bitmap and mask for the new image.

  [in] bAutoDestroy

  TRUE to specify that bitmap resources be destroyed automatically; otherwise, FALSE. The default is TRUE.

  [in] hIconHot

  Handle to the icon that contains the image for the selected state.

  [in] hBitmap

  Handle to the bitmap that contains the image for the non-selected state.

  [in] hBitmapHot

  Handle to the bitmap that contains the image for the selected state.

  [in] uiBmpResId

  Resource ID for the non-selected image.

  [in] uiBmpHotResId

  Resource ID for the selected image.

  [in] bMap3dColors

  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.

  [in] hIconDisabled

  Handle to the icon for the disabled image.

  [in] hBitmapDisabled

  Handle to the bitmap that contains the disabled image.

  [in] uiBmpDsblResID

  Resource ID of the disabled bitmap.

  [in] bAlphaBlend

  TRUE to use only 32-bit images that use the alpha channel; FALSE, to not use only alpha channel images. The default is FALSE.

  Example

  --------------------------------------------------------------------------------

  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.

  VBC#C++F#JScriptCopyCMFCButton m_Button;

  ...

  // int m_iImage

  // IDB_BTN1_32, IDB_BTN1_HOT_32, IDB_BTN1, IDB_BTN1_HOT are int macros that are #define.

  if (m_iImage == 1)

  {

  m_Button.SetImage((HBITMAP) NULL);

  }

  else

  {

  m_Button.SetImage(IDB_BTN1_32, IDB_BTN1_HOT_32);

  }


W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
1,767.090ms