void CBCGPMSOffice2007DemoView::OnFontsize () { CBCGPRibbonBar* pRibbon = ((CMainFrame*) GetTopLevelFrame ())->GetRibbonBar (); ASSERT_VALID (pRibbon); CBCGPRibbonComboBox* pSizeCombo = DYNAMIC_DOWNCAST ( CBCGPRibbonComboBox, pRibbon->FindByID (ID_FONT_FONTSIZE)); if (pSizeCombo == NULL) { return; } int nSize = GetTwipSize (pSizeCombo->GetEditText ()); if (nSize == -2) { // Restore current size: pSizeCombo->SetEditText (TwipsToPointString (GetCharFormatSelection ().yHeight)); MessageBox (_T("This is not a valid number")); return; } if ((nSize >= 0 && nSize < 20) || nSize > 32760) { return; } if (nSize > 0) { CCharFormat cf; cf.dwMask = CFM_SIZE; cf.yHeight = nSize; SetCharFormat (cf); } }