My CMDIFrameWndEx derived main frame window uses a CMFCRibbonStatusBar to which I add a CMFCRibbonLabel.
I’d like to change the text of this label at runtime:
m_pLabel->SetText(description);
m_pLabel->Redraw();
It only updates the text but not the rectangle in which to draw it. So if the original text was too short, the new string won’t be visible completely.
How do I get it to resize correctly?
Answering my own question again…
I worked around the issue by adding and removing the label instead of trying to change the text.
Code for adding the label:
Note that I’m setting an ID so I can later call
CMFCRibbonStatusBar::RemoveElement()with that ID.The calls to
RecalcLayout()andRedrawWindow()are needed to make the changes visible.Code for removing the label: