Eddie Han
Eddie Han

Reputation: 3

How can I redraw the ribbon UI Elements

I am doing a MFC Ribbon programming based on MDI environments.

I want to change the elements of the MFC Ribbon gallery button on runtime.

So I create a HBITMAP objects on runtime and using SetPallete method in CMFCToolBarImage class.

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.

Upvotes: 0

Views: 394

Answers (2)

DannyRitiu
DannyRitiu

Reputation: 91

RecalcLayout() is sometimes not enough. In that case use ForceRecalcLayout(), that will do the trick.

Upvotes: 0

xMRi
xMRi

Reputation: 15355

Try and call CMFCRibbonBar::RecalcLayout, this function forces the complete ribbon layout to be recalculated and redrawn.

Upvotes: 2

Related Questions