[英]How can I redraw the ribbon UI Elements
I am doing a MFC Ribbon programming based on MDI environments. 我正在基于MDI环境进行MFC功能区编程。
I want to change the elements of the MFC Ribbon gallery button on runtime. 我想在运行时更改MFC功能区库按钮的元素。
So I create a HBITMAP
objects on runtime and using SetPallete
method in CMFCToolBarImage
class. 因此,我在运行时创建一个
HBITMAP
对象,并在CMFCToolBarImage
类中使用SetPallete
方法。
My code is below. 我的代码如下。
CMFCRibbonGallery* pGallery = (CMFCRibbonGallery*)pRibbon->FindByID(ID_BUTTON_LABEL_CONTROL_GALLERY);
CMFCToolBarImages test;
test.SetImageSize(t);
test.AddImage(hBitmap, 0);
pGallery->Clear();
pGallery->SetPalette(test);
pGallery->RedrawIcons();
When i run this code, the ribbon gallery button is deleted, but there is no elements in the gallery button. 当我运行此代码时,功能区库按钮被删除,但库按钮中没有元素。
Strange thing is when I Minimize/Maximize the window, The Icons are visible at the button. 奇怪的是,当我最小化/最大化窗口时,图标在按钮上可见。
How can Icons are visible without minimize/maximize the window? 在不最小化/最大化窗口的情况下如何显示图标? Thanks you.
谢谢。
尝试调用CMFCRibbonBar::RecalcLayout
,此函数将强制重新计算和重绘完整的功能区布局。
RecalcLayout()
is sometimes not enough. RecalcLayout()
有时还不够。 In that case use ForceRecalcLayout()
, that will do the trick. 在那种情况下,使用
ForceRecalcLayout()
可以解决问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.