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
總結
以上是生活随笔為你收集整理的CMFCRibbonStatusBar中添加图片按钮的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 输入法智能化发展历程
- 下一篇: 联想将在CES上展示LePad平板