|
|
You should open file in binary mode.
-Saurabh
|
|
|
|
|
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);
}
|
|
|
|
|
 I just checked and the MSOffice2007Demo does cut off but not that much. Take the Demo code and replace the Home tab w/ the following and lots of labels get cutoff.
CMFCRibbonCategory* pCategory = m_wndRibbonBar.AddCategory(_T("Home\nh"), IDB_WRITE, IDB_WRITELARGE);
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);
CMFCRibbonPanel* pPanelDocuments = pCategory->AddPanel(_T("Documents"), m_PanelImages.ExtractIcon(12));
CMFCRibbonButton* pBtnPrevious(new CMFCRibbonButton(ID_EDIT_COPY, _T("Previous"), 14, -1));
pBtnPrevious->SetKeys(_T("P"));
pPanelDocuments->Add(pBtnPrevious);
CMFCRibbonButton* pBtnNext(new CMFCRibbonButton(ID_EDIT_COPY, _T("Next"), 14, -1));
pBtnNext->SetKeys(_T("N"));
pPanelDocuments->Add(pBtnNext);
pPanelDocuments->AddSeparator();
CMFCRibbonButton* pBtnCloseAll(new CMFCRibbonButton(ID_EDIT_COPY, _T("Close all"), 14, -1));
pBtnCloseAll->SetMenu(IDR_WRITE_PASTE_MENU, TRUE);
pBtnCloseAll->SetKeys(_T("DC"));
pPanelDocuments->Add(pBtnCloseAll);
pCategory->AddHidden(new CMFCRibbonButton(ID_EDIT_COPY, _T("Close all"), 14));
pCategory->AddHidden(new CMFCRibbonButton(ID_EDIT_COPY, _T("Close all except document in focus"), 14));
CMFCRibbonButton* pBtnOpenLinked(new CMFCRibbonButton(ID_EDIT_COPY, _T("Open linked"), 14, -1));
pBtnOpenLinked->SetMenu(IDR_WRITE_PASTE_MENU);
pBtnOpenLinked->SetKeys(_T("DO"));
pPanelDocuments->Add(pBtnOpenLinked);
pCategory->AddHidden(new CMFCRibbonButton(ID_EDIT_COPY, _T("Case"), 14));
pCategory->AddHidden(new CMFCRibbonButton(ID_EDIT_COPY, _T("Well"), 14));
pCategory->AddHidden(new CMFCRibbonButton(ID_EDIT_COPY, _T("Model"), 14));
pCategory->AddHidden(new CMFCRibbonButton(ID_EDIT_COPY, _T("Currency"), 0));
pCategory->AddHidden(new CMFCRibbonButton(ID_EDIT_COPY, _T("Global Parameters"), 0));
pCategory->AddHidden(new CMFCRibbonButton(ID_EDIT_COPY, _T("Preceding Case"), 14));
CMFCRibbonButton* pBtnRevert(new CMFCRibbonButton(ID_EDIT_COPY, _T("Revert"), 14, 14));
pBtnRevert->SetKeys(_T("DR"));
pPanelDocuments->Add(pBtnRevert);
CMFCRibbonPanel* pPanelOperations = pCategory->AddPanel(_T("Column operations"), m_PanelImages.ExtractIcon(12));
CMFCRibbonButton* pBtnMultiply(new CMFCRibbonButton(ID_EDIT_COPY, _T("Multiply"), 14, -1));
pBtnMultiply->SetKeys(_T("MM"));
pPanelOperations->Add(pBtnMultiply);
CMFCRibbonButton* pBtnDivide(new CMFCRibbonButton(ID_EDIT_COPY, _T("Divide"), 14, -1));
pBtnDivide->SetKeys(_T("MD"));
pPanelOperations->Add(pBtnDivide);
CMFCRibbonButton* pBtnAdd(new CMFCRibbonButton(ID_EDIT_COPY, _T("Add"), 14, -1));
pBtnAdd->SetKeys(_T("MA"));
pPanelOperations->Add(pBtnAdd);
CMFCRibbonButton* pBtnSubtract(new CMFCRibbonButton(ID_EDIT_COPY, _T("Subtract"), 14, -1));
pBtnSubtract->SetKeys(_T("MS"));
pPanelOperations->Add(pBtnSubtract);
pPanelOperations->AddSeparator();
CMFCRibbonButton* pBtnCopyDown(new CMFCRibbonButton(ID_EDIT_COPY, _T("Copy down"), 14, -1));
pBtnCopyDown->SetKeys(_T("OC"));
pPanelOperations->Add(pBtnCopyDown);
CMFCRibbonButton* pBtnEscalate(new CMFCRibbonButton(ID_EDIT_COPY, _T("Escalate"), 14, -1));
pBtnEscalate->SetKeys(_T("OE"));
pPanelOperations->Add(pBtnEscalate);
CMFCRibbonButton* pBtnDecline(new CMFCRibbonButton(ID_EDIT_COPY, _T("Decline"), 14, -1));
pBtnDecline->SetKeys(_T("OD"));
pPanelOperations->Add(pBtnDecline);
CMFCRibbonPanel* pPanelDisplay = pCategory->AddPanel(_T("Column display"), m_PanelImages.ExtractIcon(12));
CMFCRibbonButtonsGroup* pGroupPeriod = new CMFCRibbonButtonsGroup();
CMFCRibbonButton* pBtnMonthly(new CMFCRibbonButton(ID_EDIT_COPY, _T(""), 14, -1));
pBtnMonthly->SetKeys(_T("FM"));
pGroupPeriod->AddButton(pBtnMonthly);
CMFCRibbonButton* pBtnQuarter(new CMFCRibbonButton(ID_EDIT_COPY, _T(""), 14, -1));
pBtnQuarter->SetKeys(_T("FQ"));
pGroupPeriod->AddButton(pBtnQuarter);
CMFCRibbonButton* pBtnSemi(new CMFCRibbonButton(ID_EDIT_COPY, _T(""), 14, -1));
pBtnSemi->SetKeys(_T("FS"));
pGroupPeriod->AddButton(pBtnSemi);
CMFCRibbonButton* pBtnYear(new CMFCRibbonButton(ID_EDIT_COPY, _T(""), 14, -1));
pBtnYear->SetKeys(_T("FY"));
pGroupPeriod->AddButton(pBtnYear);
pPanelDisplay->Add(pGroupPeriod);
CMFCRibbonButtonsGroup* pGroupNominal = new CMFCRibbonButtonsGroup();
CMFCRibbonButton* pBtnReal(new CMFCRibbonButton(ID_EDIT_COPY, _T("Real"), 14, -1));
pBtnReal->SetKeys(_T("FR"));
pGroupNominal->AddButton(pBtnReal);
CMFCRibbonButton* pBtnNominal(new CMFCRibbonButton(ID_EDIT_COPY, _T("Nominal"), 14, -1));
pBtnNominal->SetKeys(_T("FN"));
pGroupNominal->AddButton(pBtnNominal);
pPanelDisplay->Add(pGroupNominal);
CMFCRibbonButton* pBtnRatio(new CMFCRibbonButton(ID_EDIT_COPY, _T("Ratio"), 14, 15));
pBtnRatio->SetKeys(_T("FA"));
pPanelDisplay->Add(pBtnRatio);
CMFCRibbonPanel* pPanelUnits = pCategory->AddPanel(_T("Unit settings"), m_PanelImages.ExtractIcon(12));
CMFCRibbonComboBox* pUnitTypeComboBox = new CMFCRibbonComboBox(ID_EDIT_COPY, FALSE, 14, _T("Units:"), 113);
pUnitTypeComboBox->SetKeys(_T("UU"));
pUnitTypeComboBox->AddItem(_T("Imperial"), ID_EDIT_COPY);
pUnitTypeComboBox->AddItem(_T("Metric"), ID_EDIT_COPY);
pUnitTypeComboBox->AddItem(_T("Alternate"), ID_EDIT_COPY);
pUnitTypeComboBox->SelectItem(0);
pPanelUnits->Add(pUnitTypeComboBox);
CMFCRibbonComboBox* pUnitScaleComboBox = new CMFCRibbonComboBox(ID_EDIT_COPY, FALSE, 14, _T("Scale:"), 112);
pUnitScaleComboBox->SetKeys(_T("UC"));
pUnitScaleComboBox->AddItem(_T("Small"), ID_EDIT_COPY);
pUnitScaleComboBox->AddItem(_T("Medium"), ID_EDIT_COPY);
pUnitScaleComboBox->AddItem(_T("Large"), ID_EDIT_COPY);
pUnitScaleComboBox->SelectItem(0);
pPanelUnits->Add(pUnitScaleComboBox);
pPanelUnits->EnableLaunchButton(ID_EDIT_COPY, -1, _T("US"));
CMFCRibbonPanel* pPanelResults = pCategory->AddPanel(_T("Results"), m_PanelImages.ExtractIcon(12));
CMFCRibbonButton* pBtnCalculate(new CMFCRibbonButton(ID_EDIT_COPY, _T("Calculate"), 14, 16));
pBtnCalculate->SetKeys(_T("RC"));
pPanelResults->Add(pBtnCalculate);
CMFCRibbonPanel* pPanelScenarios = pCategory->AddPanel(_T("Scenarios"), m_PanelImages.ExtractIcon(12));
CMFCRibbonButton* pBtnManageScenarios(new CMFCRibbonButton(ID_EDIT_COPY, _T("Manage"), 14, 17));
pBtnManageScenarios->SetKeys(_T("S"));
pPanelScenarios->Add(pBtnManageScenarios);
CMFCRibbonPanel* pPanelProperties = pCategory->AddPanel(_T("Columns and properties"), m_PanelImages.ExtractIcon(12));
CMFCRibbonButton* pBtnAddColumn(new CMFCRibbonButton(ID_EDIT_COPY, _T("Add"), 14, -1));
pBtnAddColumn->SetKeys(_T("PA"));
pPanelProperties->Add(pBtnAddColumn);
CMFCRibbonButton* pBtnEditColumn(new CMFCRibbonButton(ID_EDIT_COPY, _T("Edit"), 14, -1));
pBtnEditColumn->SetKeys(_T("PE"));
pPanelProperties->Add(pBtnEditColumn);
CMFCRibbonButton* pBtnRemoveColumn(new CMFCRibbonButton(ID_EDIT_COPY, _T("Remove"), 14, -1));
pBtnRemoveColumn->SetKeys(_T("PR"));
pPanelProperties->Add(pBtnRemoveColumn);
CMFCRibbonButton* pBtnAddInOptions(new CMFCRibbonButton(ID_EDIT_COPY, _T("Add-in settings"), 14, -1));
pBtnAddInOptions->SetKeys(_T("PO"));
pPanelProperties->Add(pBtnAddInOptions);
CMFCRibbonButton* pBtnDefinition(new CMFCRibbonButton(ID_EDIT_COPY, _T("Definition"), 14, -1));
pBtnDefinition->SetKeys(_T("PD"));
pPanelProperties->Add(pBtnDefinition);
CMFCRibbonButton* pBtnModelHelp(new CMFCRibbonButton(ID_EDIT_COPY, _T("Model help text"), 14, -1));
pBtnModelHelp->SetKeys(_T("PH"));
pPanelProperties->Add(pBtnModelHelp);
CMFCRibbonPanel* pPanelOilInMass = pCategory->AddPanel(_T("Oil in mass"), m_PanelImages.ExtractIcon(12));
CMFCRibbonButton* pBtnMass(new CMFCRibbonButton(ID_EDIT_COPY, _T("Mass measurement"), 14, 13));
pBtnMass->SetKeys(_T("OM"));
pPanelOilInMass->Add(pBtnMass);
CMFCRibbonButton* pBtnVolume(new CMFCRibbonButton(ID_EDIT_COPY, _T("Volume measurement"), 14, 13));
pBtnVolume->SetKeys(_T("OV"));
pPanelOilInMass->Add(pBtnVolume);
|
|
|
|
|
Hi Dale,
Sorry for the delayed response. I am in the office working and participating in the forum part-time as time allows. I have added the code you suggested to the MSOffice2007Demo sample. I am not able to reproduce these cut-off issues you are describing. Would it be possible for you to upload a screenshot so we can see what your talking about?
Actually... I do see a drawing bug here in my office but it is in the "Oil in Mass" Panel. Here on my development box the text is drawing outside of the panel into the non-client area when I resize the window.
Best Wishes,
-David Delaune
|
|
|
|
|
Could this be an XP issue (are you using XP or Vista or Windows7)?
How do u upload an jpeg to the message board?
|
|
|
|
|
Hi Dale,
My main development workstation is Windows7. Give me a few minutes and I will test the binary on Win2k and XP.
Dale Haessel wrote: How do u upload an jpeg to the message board?
The forum does not support embedded images. I would suggest uploading to a free image hosting provider and posting the link here.
http://www.bing.com/search?q=free+image+hosting&src=IE-SearchBox&FORM=IE8SRC[^]
Best Wishes,
-David Delaune
|
|
|
|
|
Thx, here is what I see given my original code from 1st email embedded into MSOffice2007Demo
http://img21.imageshack.us/img21/9932/ribbonl.jpg[^]
Notice how the multiply shows up but not the text to all the other buttons around it. Multiply is larger text than say add so Add should show up if Multiply shows. Any help would be most appreciated. As per everything, this is on XP => if it works on Vista/Windows 7, but not XP that would definitely be worth knowing.
|
|
|
|
|
Hi Dale,
I have tested the modified MSOffice2007Demo binaries on both Win2k and WindowsXP. The panels are drawing the same on all platforms. The only thing that I would classify as being strange... is that in your 'Column operations' pane the first item is 'Multiply' and for some reason this item is the last to be cropped. Even though 'Add' and 'Divide' have a smaller character width.
Is this what you are referring to when you say labels cutting off?
Best Wishes,
-David Delaune
|
|
|
|
|
|
Hi Dale,
Thats exactly the same behavior I see in the MFC Feature Pack Ribbon Panel. I spent a few minutes debugging the issue and was able to track it down to the file:
\Microsoft Visual Studio 9.0\VC\atlmfc\src\mfc\afxribbonpanel.cpp
And further into the CMFCRibbonPanel::Reposition function. I stopped debugging the issue at this point because it was taking more time than I was willing to invest. You may also be interested in the CMFCRibbonBaseElement::SetCompactMode[^] function. I did not spend the time to check if this function was able to fix the labels. You may want to continue the research.
Good Luck,
-David Delaune
|
|
|
|
|
I have basically the following code
<br />
CMFCRibbonButton* pBtnPeepHelp = new CMFCRibbonButton(ID_HELP2, _T("Peep &Help"), 10, 11, TRUE);<br />
pBtnPeepHelp->SetToolTipText(_T("Peep Help"));<br />
pBtnPeepHelp->SetDescription(_T("Get help using Peep."));<br />
pBtnHelp->AddSubItem(pBtnPeepHelp);<br />
<br />
CMFCRibbonButton* pBtnShowHelp = new CMFCRibbonCheckBox(ID_HELP_SHOWHELPONSTARTUP, _T("Show Help &On Startup"));<br />
pBtnShowHelp->SetToolTipText(_T("Show Help On Startup"));<br />
pBtnShowHelp->SetDescription(_T("Show Help file when starting Peep."));<br />
pBtnPeepHelp->AddSubItem(pBtnShowHelp);<br />
<br />
pMainPanel->Add(pBtnHelp);<br />
When I look at the Customize Quick Access Toolbar->More Commands for the Main Panel, Peep Help shows up twice. I would like to avoid it showing up multiple times.
|
|
|
|
|
Hi Dale,
The only way I am able to duplicate the issue you are describing is by calling CMFCRibbonMainPanel::Add[^] multiple times with the same element pointer. This causes my Quick Access Toolbar to have multiple entries for my test element inside the 'More Commands' customization dialog.
Can you confirm that this line is executing only once? And could you confirm that the pBtnHelp element pointer is only used once?
pMainPanel->Add(pBtnHelp);
Best Wishes,
-David Delaune
|
|
|
|
|
Thanks, however I only call pMainPanel->Add(pBtnHelp); once.
I forgot the following code in my previous snipet that codes above, everything else the same:
<br />
CMFCRibbonButton* pBtnHelp = new CMFCRibbonButton (ID_HELP, _T("&Help"), 10, 11);<br />
pBtnHelp->SetKeys(_T("H"));<br />
pBtnHelp->AddSubItem(new CMFCRibbonLabel(_T("Help")));<br />
It still shows 2 Help in the Quick Access Menu.
|
|
|
|
|
Hi Dale,
I am using the MFC Feature Pack Sample [^]located at:
\Samples\1033\Visual C++ 2008 Feature Pack\RibbonMDI
I pasted the code snippets you have shown into the InitRibbon() function. It compiles cleanly after I added resource definitions. The items only show once for me. I am not able to reproduce the issue you have described.
Best Wishes,
-David Delaune
|
|
|
|
|
Thx, for looking into this, here is image I see in XP:
http://img260.imageshack.us/img260/2356/peephelp.jpg[^]
I used the MDIRibbon InitRibbon and added the following:
to resource.h
#define ID_HELP2 33016
#define ID_HELP_SHOWHELPONSTARTUP 33017
to mainfrm.cpp just after pPanelWindow->Add (pBtnWindows);
CMFCRibbonButton* pBtnHelp = new CMFCRibbonButton (ID_HELP, _T("&Help"), 10, 11);
pBtnHelp->SetKeys(_T("H"));
pBtnHelp->AddSubItem(new CMFCRibbonLabel(_T("Help")));
CMFCRibbonButton* pBtnPeepHelp = new CMFCRibbonButton(ID_HELP2, _T("Peep &Help"), 10, 11, TRUE);
pBtnPeepHelp->SetToolTipText(_T("Peep Help"));
pBtnPeepHelp->SetDescription(_T("Get help using Peep."));
pBtnHelp->AddSubItem(pBtnPeepHelp);
CMFCRibbonButton* pBtnShowHelp = new CMFCRibbonCheckBox(ID_HELP_SHOWHELPONSTARTUP, _T("Show Help &On Startup"));
pBtnShowHelp->SetToolTipText(_T("Show Help On Startup"));
pBtnShowHelp->SetDescription(_T("Show Help file when starting Peep."));
pBtnPeepHelp->AddSubItem(pBtnShowHelp);
pPanelWindow->Add (pBtnHelp);
|
|
|
|
|
Hi Dale,
I have confirmed the behavior you are describing. I am now getting the same results. I do not know if this behavior is by design.
However do you really need the "Peep &Help" to have a menu handler? If you give this menu item an ID of zero it will be ommitted from the customization dialog.
Best Wishes,
-David Delaune
|
|
|
|
|
I have some problems getting the screen coordinates of the client area of my mainframe and later increasing if the right side coordinate of the mainframes client Rect is smaller than the views right side coordinate.
For testing i positioned the view fitting in the mainframes client area(By Mouse). So the outside coordintes of the View Window should be the same as the inside coordinates of the main frame client area.
But it isn't!!
What am I doing wrong?
Code inside the view class:
GetWindowRect(ViewWindo wRectSC);
pMainFrame->GetClientRect(MainFrameClientRectCCMain);
MainFrameClientRectSC=MainFrameClientRectCCMain;
pMainFrame->ClientToScreen(MainFrameClientRectSC);
But
ViewWindowRectSC.right is not MainFrameClientRectSC.right
f.e.
ViewWindowRectSC: {top=99 bottom=918 left=14 right=1267}
MainFrameClientRectSC {top=42 bottom=964 left=4 right=1277}
I tried a lot but it is getting more and more unclear.
For example i tried to find frames or bars or something else with the GetSystemMetrics() function because i was thinking that there could be coordinate values not bringing these into account these. Didn't help.
Also tried to calculate the outside of the view window by first using
GetClientRect(ViewClientRectCC) and then
AdjustWindowRectEx(ViewClientRectCC,GetStyle(),1,GetExStyle());
Didn't help.
Thanks a lot
Hubert
[solved]
modified on Wednesday, November 11, 2009 4:29 AM
|
|
|
|
|
If your view is going to be bigger than the frame size, you must ideally use CScrollView so that the view is scrollable and you can also use CScrollView::ResizeParentToFit[^] to resize the frame to the size of the view.
|
|
|
|
|
Thanks for your answer.
I just reduced the problem to the described upstract conditions. In real i am setting views to before stored positions when i rebuild the application or the user opens a config file. The user is able to load a defined graphview which has coordinates which sometimes d'ont fit into the frame. (If the frame was smaller during constructing of the graphviews)
The use of scrollviews would be possible but i wouldn't like to have scrollbars. I constructed tabs in this view and in each tab there are one or more graphs. But there are also more then one view in the mainframe. The user has to positioned them once and he and others can open these configuration from file.
How does CScrollView::ResizeParentToFit increase the Mainframe? Just at the view coordinates which are bigger then the accordant one of the MainFrame?
Hubert
|
|
|
|
|
My own answer to my own question. A little stupid but maybe someone can use my solution to save some times and delivers new idears.
I solved my problem as follows:
First i used the sysinternals freeware zoom tool (http://technet.microsoft.com/de-de/sysinternals/bb897434%28en-us%29.aspx[^])to find the sizes of frames and borders.
Then the second tool the winspector tool from gipsysoft (http://www.windows-spy.com/[^] )to find out coordinates and classes of the interesting frames.
With this informations i was looking for parent() parent()....... frames and windows until i found the windows and frames with the correct coordinates.
The resulting code as follows:
CRect MainFrameClientRect,MainFrameClientRectSC,ViewsFrameWindowRect,PPWindowRectSC;
CWnd* PP;
PP=GetParent()->GetParent();
PP->GetClientRect(MainFrameClientRect);
MainFrameClientRectSC=MainFrameClientRect;
PP->ClientToScreen(MainFrameClientRectSC);
GetParentFrame()->GetWindowRect(ViewsFrameWindowRect);
CMainFrame* pMainFrame=(CMainFrame* )theApp.GetMainWnd();
WINDOWPLACEMENT MainFramePlacement;
MainFramePlacement.length = sizeof(WINDOWPLACEMENT);
::GetWindowPlacement(pMainFrame->m_hWnd,&MainFramePlacement);
if(ViewsFrameWindowRect.right>MainFrameClientRectSC.right)
MainFramePlacement.rcNormalPosition.right+=ViewsFrameWindowRect.right-MainFrameClientRectSC.right;
if(ViewsFrameWindowRect.bottom>MainFrameClientRectSC.bottom)
MainFramePlacement.rcNormalPosition.bottom+=ViewsFrameWindowRect.bottom-MainFrameClientRectSC.bottom;
pMainFrame->SetWindowPos(NULL,
MainFramePlacement.rcNormalPosition.left,
MainFramePlacement.rcNormalPosition.top,
MainFramePlacement.rcNormalPosition.right-MainFramePlacement.rcNormalPosition.left,
MainFramePlacement.rcNormalPosition.bottom-MainFramePlacement.rcNormalPosition.top,
SWP_NOZORDER);
pMainFrame->ShowWindow(theApp.m_nCmdShow);
pMainFrame->UpdateWindow();
Thanks to all which were looking at my question and thinking about a solution but couldn't help.
|
|
|
|
|
Hi,
I am trying to develop a console application, in which i am creating a new process (executable is c:\windows\system32\cmd.exe).
I am able to see the newly created process cmd.exe (console windows). but how can i execute some commands in the newly created console window programatically?
if( !CreateProcess("C:\\windows\\system32\\cmd.exe",
NULL, // Command line.
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
CREATE_NEW_CONSOLE, // No creation flags.
NULL, // Use parent's environment block.
NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi ) // Pointer to PROCESS_INFORMATION structure.
)
{
printf( "CreateProcess failed (%d).\n", GetLastError() );
return;
}
|
|
|
|
|
The second parameter in the CreateProcess Function[^] is the commandline. You can pass your arguments there such as the path to a batch file. This is probably what your looking for.
If you are looking to do some advanced interaction with the console then it would be possible to overide the hStdInput handle of the STARTUPINFO Structure[^] with a handle to a named pipe or something.
Best Wishes,
-David Delaune
|
|
|
|
|
Hi David,
I think the second argument is the command line argument to the process that we are creating. i want to execute a command after creating the cmd.exe process.
for example, how can i execute a "DIR" command once i create a cmd.exe process? can i use WriteConsole() to execute the command?
Thanks in advance...
--Dev
|
|
|
|
|
devgo wrote: for example, how can i execute a "DIR" command once i create a cmd.exe process?
You mean like:
CreateProcess(NULL, "cmd.exe /c dir", NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); Using Randor's second suggestion will also work but is more involved.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|