The MFC example never cuts of button labels but my example cuts off when user resizes window. Even CMFCRibbonBar::ForceRecalcLayout doesn't help.
If we don't use icons, it doesn't cutoff (almost as if it calculates wrong amount of space used for certain icons and then figures out it doesn't have enough room for the label).
See code below => Just wondering if anyone else has seen this or has a way of avoiding it. In our code below, the Divide, Multiply, etc., Next, etc. would cutoff. It is really weird.
CMFCRibbonCategory* pCategory = m_wndRibbonBar.AddCategory(_T("&Home"), IDB_RIBBON_TAB_HOME_SMALL, IDB_RIBBON_TAB_HOME_LARGE);
CString strID = RIBBON_TAB_HOME + szSeperator + RIBBON_GP_CLIPBOARD;
if (_ShouldDisplayRibbonControlGroup(piRibbon, strID, strLabel))
{
CMFCRibbonPanel* pPanelClipboard = pCategory->AddPanel(_T("Clipboard"), m_PanelImages.ExtractIcon(12));
CMFCRibbonButton* pBtnPaste(new CMFCRibbonButton(ID_EDIT_PASTE, _T("Paste"), 12, 13));
pBtnPaste->SetKeys(_T("V"));
pPanelClipboard->Add(pBtnPaste);
CMFCRibbonButton* pBtnCut(new CMFCRibbonButton(ID_EDIT_CUT, _T("Cut"), 13, -1));
pBtnCut->SetKeys(_T("X"));
pPanelClipboard->Add(pBtnCut);
CMFCRibbonButton* pBtnCopy(new CMFCRibbonButton(ID_EDIT_COPY, _T("Copy"), 14, -1));
pBtnCopy->SetKeys(_T("C"));
pPanelClipboard->Add(pBtnCopy);
}
strID = RIBBON_TAB_HOME + szSeperator + RIBBON_GP_DOCUMENTS;
if (_ShouldDisplayRibbonControlGroup(piRibbon, strID, strLabel))
{
CMFCRibbonPanel* pPanelDocuments = pCategory->AddPanel(_T("Documents"), m_PanelImages.ExtractIcon(18));
CMFCRibbonButton* pBtnPrevious(new CMFCRibbonButton(ID_FILE_PREV_WELL, _T("Previous"), 71, -1));
pBtnPrevious->SetKeys(_T("P"));
pPanelDocuments->Add(pBtnPrevious);
CMFCRibbonButton* pBtnNext(new CMFCRibbonButton(ID_FILE_NEXT_WELL, _T("Next"), 70, -1));
pBtnNext->SetKeys(_T("N"));
pPanelDocuments->Add(pBtnNext);
pPanelDocuments->AddSeparator();
CMFCRibbonButton* pBtnCloseAll(new CMFCRibbonButton(ID_CLOSE_BTN, _T("Close all"), 72, -1));
pBtnCloseAll->SetMenu(IDR_CLOSE_ALL_MENU, TRUE);
pBtnCloseAll->SetKeys(_T("DC"));
pPanelDocuments->Add(pBtnCloseAll);
pCategory->AddHidden(new CMFCRibbonButton(ID_CLOSE_ALL, _T("Close all"), 72));
pCategory->AddHidden(new CMFCRibbonButton(ID_CLOSE_ALL_EXCEPT, _T("Close all except document in focus"), 144));
CMFCRibbonButton* pBtnOpenLinked(new CMFCRibbonButton(ID_OPEN_LINKED, _T("Open linked"), 73, -1));
pBtnOpenLinked->SetMenu(IDR_OPEN_LINKED_MENU);
pBtnOpenLinked->SetKeys(_T("DO"));
pPanelDocuments->Add(pBtnOpenLinked);
pCategory->AddHidden(new CMFCRibbonButton(ID_SHOW_CASE, _T("Case"), 58));
pCategory->AddHidden(new CMFCRibbonButton(ID_SHOW_FORECAST, _T("Well"), 127));
pCategory->AddHidden(new CMFCRibbonButton(ID_OPEN_LINKED_MODEL, _T("Model"), 66));
pCategory->AddHidden(new CMFCRibbonButton(ID_OPEN_LINKED_CURRENCY, _T("Currency"), 0));
pCategory->AddHidden(new CMFCRibbonButton(ID_OPEN_LINKED_GLOBAL_PARM, _T("Global Parameters"), 0));
pCategory->AddHidden(new CMFCRibbonButton(ID_OPEN_LINKED_PRECEEDING_CASE, _T("Preceding Case"), 58));
CMFCRibbonButton* pBtnRevert(new CMFCRibbonButton(ID_REVERT_TO_LAST_SAVED, _T("Revert"), 18, 14));
pBtnRevert->SetKeys(_T("DR"));
pPanelDocuments->Add(pBtnRevert);
}
strID = RIBBON_TAB_HOME + szSeperator + RIBBON_GP_COLUMN_OP;
if (_ShouldDisplayRibbonControlGroup(piRibbon, strID, strLabel))
{
CMFCRibbonPanel* pPanelOperations = pCategory->AddPanel(_T("Column operations"), m_PanelImages.ExtractIcon(96));
CMFCRibbonButton* pBtnMultiply(new CMFCRibbonButton(ID_OPERATION_MATH_MULTIPLY, _T("Multiply"), 50, -1));
pBtnMultiply->SetKeys(_T("MM"));
pPanelOperations->Add(pBtnMultiply);
CMFCRibbonButton* pBtnDivide(new CMFCRibbonButton(ID_OPERATION_MATH_DIVIDE, _T("Divide"), 51, -1));
pBtnDivide->SetKeys(_T("MD"));
pPanelOperations->Add(pBtnDivide);
CMFCRibbonButton* pBtnAdd(new CMFCRibbonButton(ID_OPERATION_MATH_ADD, _T("Add"), 48, -1));
pBtnAdd->SetKeys(_T("MA"));
pPanelOperations->Add(pBtnAdd);
CMFCRibbonButton* pBtnSubtract(new CMFCRibbonButton(ID_OPERATION_MATH_SUBTRACT, _T("Subtract"), 49, -1));
pBtnSubtract->SetKeys(_T("MS"));
pPanelOperations->Add(pBtnSubtract);
pPanelOperations->AddSeparator();
CMFCRibbonButton* pBtnCopyDown(new CMFCRibbonButton(ID_OPERATION_DUP, _T("Copy down"), 45, -1));
pBtnCopyDown->SetKeys(_T("OC"));
pPanelOperations->Add(pBtnCopyDown);
CMFCRibbonButton* pBtnEscalate(new CMFCRibbonButton(ID_OPERATION_ESCALATE, _T("Escalate"), 47, -1));
pBtnEscalate->SetKeys(_T("OE"));
pPanelOperations->Add(pBtnEscalate);
CMFCRibbonButton* pBtnDecline(new CMFCRibbonButton(ID_OPERATION_DECLINE, _T("Decline"), 46, -1));
pBtnDecline->SetKeys(_T("OD"));
pPanelOperations->Add(pBtnDecline);
}
strID = RIBBON_TAB_HOME + szSeperator + RIBBON_GP_COLUMN_DISPLAY;
if (_ShouldDisplayRibbonControlGroup(piRibbon, strID, strLabel))
{
CMFCRibbonPanel* pPanelDisplay = pCategory->AddPanel(_T("Column display"), m_PanelImages.ExtractIcon(95));
CMFCRibbonButtonsGroup* pGroupPeriod = new CMFCRibbonButtonsGroup();
CMFCRibbonButton* pBtnMonthly(new CMFCRibbonButton(ID_DISPLAY_MONTH, _T(""), 41, -1));
pBtnMonthly->SetKeys(_T("FM"));
pGroupPeriod->AddButton(pBtnMonthly);
CMFCRibbonButton* pBtnQuarter(new CMFCRibbonButton(ID_DISPLAY_QUARTER, _T(""), 42, -1));
pBtnQuarter->SetKeys(_T("FQ"));
pGroupPeriod->AddButton(pBtnQuarter);
CMFCRibbonButton* pBtnSemi(new CMFCRibbonButton(ID_DISPLAY_SEMI, _T(""), 43, -1));
pBtnSemi->SetKeys(_T("FS"));
pGroupPeriod->AddButton(pBtnSemi);
CMFCRibbonButton* pBtnYear(new CMFCRibbonButton(ID_DISPLAY_YEAR, _T(""), 44, -1));
pBtnYear->SetKeys(_T("FY"));
pGroupPeriod->AddButton(pBtnYear);
pPanelDisplay->Add(pGroupPeriod);
CMFCRibbonButtonsGroup* pGroupNominal = new CMFCRibbonButtonsGroup();
CMFCRibbonButton* pBtnReal(new CMFCRibbonButton(ID_OPERATION_REAL, _T("Real"), -1, -1));
pBtnReal->SetKeys(_T("FR"));
pGroupNominal->AddButton(pBtnReal);
CMFCRibbonButton* pBtnNominal(new CMFCRibbonButton(ID_OPERATION_NOMINAL, _T("Nominal"), -1, -1));
pBtnNominal->SetKeys(_T("FN"));
pGroupNominal->AddButton(pBtnNominal);
pPanelDisplay->Add(pGroupNominal);
CMFCRibbonButton* pBtnRatio(new CMFCRibbonButton(ID_OPERATION_RATIO, _T("Ratio"), 19, 15));
pBtnRatio->SetKeys(_T("FA"));
pPanelDisplay->Add(pBtnRatio);
}
strID = RIBBON_TAB_HOME + szSeperator + RIBBON_GP_UNIT_SETTINGS;
if (_ShouldDisplayRibbonControlGroup(piRibbon, strID, strLabel))
{
CMFCRibbonPanel* pPanelUnits = pCategory->AddPanel(_T("Unit settings"), m_PanelImages.ExtractIcon(98));
CPeepRibbonComboBox* pUnitTypeComboBox = new CPeepRibbonComboBox(ID_UNIT_TYPE, FALSE, 50, _T("Units:"), 113);
pUnitTypeComboBox->SetKeys(_T("UU"));
pUnitTypeComboBox->AddItem(_T("Imperial"), ID_UNIT_TYPE_IMPERIAL);
pUnitTypeComboBox->AddItem(_T("Metric"), ID_UNIT_TYPE_METRIC);
pUnitTypeComboBox->AddItem(_T("Alternate"), ID_UNIT_TYPE_ALTERNATE);
pUnitTypeComboBox->SelectItem(0);
pPanelUnits->Add(pUnitTypeComboBox);
CPeepRibbonComboBox* pUnitScaleComboBox = new CPeepRibbonComboBox(ID_UNIT_SCALE, FALSE, 50, _T("Scale:"), 112);
pUnitScaleComboBox->SetKeys(_T("UC"));
pUnitScaleComboBox->AddItem(_T("Small"), ID_UNIT_SCALE_SMALL);
pUnitScaleComboBox->AddItem(_T("Medium"), ID_UNIT_SCALE_MEDIUM);
pUnitScaleComboBox->AddItem(_T("Large"), ID_UNIT_SCALE_LARGE);
mUnitScale unitScale = DefUnitScale();
switch (unitScale)
{
case UNITS_SMALL:
{
pUnitScaleComboBox->SelectItem(0);
break;
}
case UNITS_MEDIUM:
{
pUnitScaleComboBox->SelectItem(1);
break;
}
case UNITS_LARGE:
{
pUnitScaleComboBox->SelectItem(2);
break;
}
}
pPanelUnits->Add(pUnitScaleComboBox);
pPanelUnits->EnableLaunchButton(ID_UNIT_SETTINGS, -1, _T("US"));
}
strID = RIBBON_TAB_HOME + szSeperator + RIBBON_GP_RESULTS;
if (_ShouldDisplayRibbonControlGroup(piRibbon, strID, strLabel))
{
CMFCRibbonPanel* pPanelResults = pCategory->AddPanel(_T("Results"), m_PanelImages.ExtractIcon(20));
CMFCRibbonButton* pBtnCalculate(new CMFCRibbonButton(ID_PEEP_CALC, _T("Calculate"), 20, 16));
pBtnCalculate->SetKeys(_T("RC"));
pPanelResults->Add(pBtnCalculate);
}
strID = RIBBON_TAB_HOME + szSeperator + RIBBON_GP_SCENARIOS;
if (_ShouldDisplayRibbonControlGroup(piRibbon, strID, strLabel))
{
CMFCRibbonPanel* pPanelScenarios = pCategory->AddPanel(_T("Scenarios"), m_PanelImages.ExtractIcon(21));
CMFCRibbonButton* pBtnManageScenarios(new CMFCRibbonButton(ID_SCENARIO, _T("Manage"), 21, 17));
pBtnManageScenarios->SetKeys(_T("S"));
pPanelScenarios->Add(pBtnManageScenarios);
}
strID = RIBBON_TAB_HOME + szSeperator + RIBBON_GP_COLUMN_PROP;
if (_ShouldDisplayRibbonControlGroup(piRibbon, strID, strLabel))
{
CMFCRibbonPanel* pPanelProperties = pCategory->AddPanel(_T("Columns and properties"), m_PanelImages.ExtractIcon(97));
CMFCRibbonButton* pBtnAddColumn(new CMFCRibbonButton(ID_EDIT_ADD_COL, _T("Add"), 52, -1));
pBtnAddColumn->SetKeys(_T("PA"));
pPanelProperties->Add(pBtnAddColumn);
CMFCRibbonButton* pBtnEditColumn(new CMFCRibbonButton(ID_EDIT_EDIT_COL, _T("Edit"), 54, -1));
pBtnEditColumn->SetKeys(_T("PE"));
pPanelProperties->Add(pBtnEditColumn);
CMFCRibbonButton* pBtnRemoveColumn(new CMFCRibbonButton(ID_EDIT_DEL_COL, _T("Remove"), 53, -1));
pBtnRemoveColumn->SetKeys(_T("PR"));
pPanelProperties->Add(pBtnRemoveColumn);
CMFCRibbonButton* pBtnAddInOptions(new CMFCRibbonButton(ID_CASE_ADDIN_DATA, _T("Add-in settings"), 55, -1));
pBtnAddInOptions->SetKeys(_T("PO"));
pPanelProperties->Add(pBtnAddInOptions);
CMFCRibbonButton* pBtnDefinition(new CMFCRibbonButton(ID_COLUMN_DEFINITION, _T("Definition"), 56, -1));
pBtnDefinition->SetKeys(_T("PD"));
pPanelProperties->Add(pBtnDefinition);
CMFCRibbonButton* pBtnModelHelp(new CMFCRibbonButton(ID_MODEL_HELP_TEXT, _T("Model help text"), 57, -1));
pBtnModelHelp->SetKeys(_T("PH"));
pPanelProperties->Add(pBtnModelHelp);
}
bool bMassLicense = GETAPP->HasMassLicense();
if (bMassLicense)
{
CMFCRibbonPanel* pPanelOilInMass = pCategory->AddPanel(_T("Oil in mass"), m_PanelImages.ExtractIcon(99));
CMFCRibbonButton* pBtnMass(new CMFCRibbonButton(ID_QUANTITY_MASS, _T("Mass measurement"), 99, 97));
pBtnMass->SetKeys(_T("OM"));
pPanelOilInMass->Add(pBtnMass);
CMFCRibbonButton* pBtnVolume(new CMFCRibbonButton(ID_QUANTITY_VOLUME, _T("Volume measurement"), 100, 98));
pBtnVolume->SetKeys(_T("OV"));
pPanelOilInMass->Add(pBtnVolume);
}
|