1

How do I rename the MFC ribbon panel? I have a related problem. My ribbon's original captions in the resource are in Language A. I translate everything in Language B, including the panels' names(using a method, similar to the offered in the mentioned topic). But when I shrink the window so that some of(or all) the panels collapse, their names go back to Language A. When I widen the window, the panels' names are translated into Language B again. Still haven't found a solution. Anyone got an idea? :/ EDIT: We use a translator class which works with flags, so, according to the language flag, it translates strings which are then applied to the categories, buttons etc. I made my own panel class which derives from CMFCRibbonPanel. I added this method:

void CRibbonPanel::setName(CString name)  
{  
    m_strName = name;  
}  

Then I make a loop to find and edit every panel's name:

(CRibbonPanel*)thePanel->setName(theNewName);  

It works fine but when the panels are collapsed, their captions go back to the default language.

Community
  • 1
  • 1
Stoyanov
  • 71
  • 8
  • What Kind of tranlsation do you use? Satellite DLLs? – xMRi Sep 04 '14 at 21:05
  • Can you post the code you use to rename the panel? – thomiel Sep 05 '14 at 00:48
  • No, we're not using satellite DLLs, we use a translator class which works with flags, so, according to the language flag, it translates strings which are then appliet to the categories, buttons etc. I made my own panel class which derives from CMFCRibbonPanel. I added this method: `void CRibbonPanel::setName(CString name)` `{` `m_strName = name;` `}` It works fine but when the panels are collapsed, their captions go back to the default language. – Stoyanov Sep 08 '14 at 07:08
  • Uhhh, markdown doesn't work propperly. I can't put the code on separate lines :/ – Stoyanov Sep 08 '14 at 07:09
  • So you did your own Wrapper for CMFCRibbonPanel? But from your code it isn't clear how your m_strName interacts with the base class. Better post the whole class in an edit to your original question for me to get a picture. – thomiel Sep 10 '14 at 10:52

1 Answers1

2

The collapsed panel title is stored in a "default panel button". Extend the accessor class like this:

class CRibbonPanel : public CMFCRibbonPanel
{
public:
    void SetName(CString& name ) 
    { m_strName = name; };

    CMFCRibbonDefaultPanelButton & GetDefBtn() 
    { return m_btnDefault; }
};

Then use like this:

void ChangeText(CMFCRibbonPanel * pPanel, CString & newText)
{
    auto pMyPanel = (CRibbonPanel *)(pPanel);
    auto & defBtn = pMyPanel->GetDefBtn();
    defBtn.SetText(newText);
}

The MFC ribbon interface is not a perfect abstraction. Fortunately, Microsoft distributes the source code for the ribbon implementation. On my machine, the panel code is found in:

C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\atlmfc\src\mfc\afxribbonpanel.cpp

Mikael
  • 41
  • 3
  • Thanks! I don't work there anymore but I just sent them the link. It appears they've already fixed the problem this way or another :) – Stoyanov Mar 06 '15 at 19:09