CMFCRibbonStatusBar中添加图片按钮

今天遇到了问题,网上down的

Here's how it works:

1. Create aCMFCRibbonButtonsGroup that will hold the status icon and add it to CMFCRibbonStatusBar

2. Create a CMFCToolBarImagesobject and add status icons via AddIcon() .

3. Register theCMFCToolbarImages to the RibbonButtonsGroup using SetImages() .For a status Icon, the pHotImages parameter may be set to NULL, since thebutton won't get a message handler assigned anyway. Note however, that both thefirst and the second parameter must be set. If the third is omitted, the iconwill be grayed out for disables buttons and if the first is omitted, no icons willbe displayed at all.

4. Create a new CMFCRibbonButtonand add it to the ButtonsGroup via AddButton() .Do *not* assign an Icon to it.

5. Obtain a pointer to thebutton using CMFCRibbonButtonsGroup::GetButton() .Then call CMFCRibbonButton::SetImageIndex() withthe appropriate index of the icon in the ToolBarImages object.

 

This approach works just fine,except for one minor detail: I was using 16x16 icons as status icons andnoticed that they get cropped on display to 16x15, i.e. the bottom row ofpixels is not displayed. A quick fix for this would be to specify the icon'sdimensions as 16x15 when callingLoadImage() ,but I wonder why this is necessary in the first place. I guess theCMFCRibbonButtonsGroup is to blame for this, though I don't know that classwell enough to claim anything for certain.

Edit:Turns out it really is CMFCToolBarImages's fault. For some reason, the defaulticon size here is 16x15. This can be changed by callingCMFCToolBarImages::SetImageSize() before adding the icons.

转载于:https://www.cnblogs.com/cyangyang/archive/2010/12/20/1912161.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值