CMFCRibbonButton constructor with HICON doesn‘t work properly because even though my icons are only 16x16
the button appear as 32x32.
使用HICON作为参数构建的RibbonButton即便指定用16X16的小图标,但最后显示在界面上仍是32X32的大图标。
class CSmallIconButton : public CMFCRibbonButton { public: CSmallIconButton (UINT nID, LPCTSTR lpszText, HICON hIcon) : CMFCRibbonButton(nID, lpszText, NULL, FALSE, hIcon) { } virtual CSize GetImageSize (RibbonImageType type) const { if (type == RibbonImageLarge || m_hIconSmall == NULL) { return CSize(0, 0); } CSize sizeIcon(16, 16); if (afxGlobalData.GetRibbonImageScale () != 1.) { sizeIcon.cx = (int) (.5 + afxGlobalData.GetRibbonImageScale () * sizeIcon.cx); sizeIcon.cy = (int) (.5 + afxGlobalData.GetRibbonImageScale () * sizeIcon.cy); } return sizeIcon; } virtual void DrawImage (CDC* pDC, RibbonImageType type, CRect rectImage) { ASSERT_VALID (this); ASSERT_VALID (pDC); if (type != RibbonImageSmall || m_hIconSmall == NULL) { return; } CSize sizeIcon = GetImageSize(type); ::DrawIconEx (pDC->GetSafeHdc (), rectImage.left, rectImage.top, m_hIconSmall, sizeIcon.cx, sizeIcon.cy, 0, NULL, DI_NORMAL); } };后来发现,MainPannel上的CMFCRibbonMainPanelButton也是如此,使用类似的方法即可。
CMFCRibbonButton使用HICON作为参数的构造函数BUG,布布扣,bubuko.com
CMFCRibbonButton使用HICON作为参数的构造函数BUG
原文地址:http://blog.csdn.net/giantchen547792075/article/details/37928027