Crash/Assertion after calling ForceRecalcLayout

268 views Asked by At

I have added Ribbon to an existing MFC application.

The ribbon is created using the Editor.

In one of the panel I have a Custom CMFCRibbonGallery (derived from) whose contents (icon) I change dynamically. (It is much like the Styles Gallery in Excel.

  1. After every time I change the contents I call ForceRecalcLayout which most of the time results in an Assert usually on m_pHighlighted or m_pPressed. Please see the attached snaphot1.jpeg, this Assert happened while I was moving the mouse over the Ribbon Gallery elements (Expanded mode popup) while ForceRecalcLayout was called.
  2. On a different use case if I add the Sub Item (like we have "New Cell Style" in Styles Gallery of Excel) to the QAT using the context menu and then try to create a New cell style I get an Assert on the CMFCRibbonButton. Refer snapshot2.jpg
1

There are 1 answers

0
xMRi On

When just the icon changes it is sufficient to invalidate the ribbon.

Only if the size of the individual items are changed you Need to call RecalcLayout.

I see no reason to call ForceRecalsLayout.