void CMSOffice2007DemoView::OnFontsize() { CMFCRibbonBar* pRibbon = ((CMainFrame*) GetTopLevelFrame())->GetRibbonBar(); ASSERT_VALID(pRibbon); CMFCRibbonComboBox* pSizeCombo = DYNAMIC_DOWNCAST(CMFCRibbonComboBox, pRibbon->FindByID(ID_FONT_FONTSIZE)); if (pSizeCombo == NULL) { return; } int nSize = GetTwipSize(pSizeCombo->GetEditText()); if (nSize == -2 || (nSize >= 0 && nSize < 20) || nSize > 32760) { // Restore current size: pSizeCombo->SetEditText (TwipsToPointString (GetCharFormatSelection ().yHeight)); MessageBox (_T("The number must be between 1 and 1638.")); return; } if (nSize > 0) { CCharFormat cf; cf.dwMask = CFM_SIZE; cf.yHeight = nSize; SetCharFormat(cf); } }
void CEditFrameView::OnFontSize () { CBCGPRibbonBar* pRibbon = ((CEditFrameDialog*) GetTopLevelFrame ())->GetRibbonBar (); ASSERT_VALID (pRibbon); CBCGPRibbonComboBox* pSizeCombo = DYNAMIC_DOWNCAST ( CBCGPRibbonComboBox, pRibbon->FindByID (ID_FONT_SIZE)); if (pSizeCombo == NULL) { return; } int nSize = GetTwipSize (pSizeCombo->GetItem (-1)); if (nSize == -2) { return; } if ((nSize >= 0 && nSize < 20) || nSize > 32760) { return; } if (nSize > 0) { CCharFormat cf; cf.dwMask = CFM_SIZE; cf.yHeight = nSize; SetCharFormat (cf); } }
void CSizeComboBox::SetTwipSize(int nTwips) { if (nTwips != GetTwipSize()) { TCHAR buf[10]; TwipsToPointString(buf, nTwips); SetTheText(buf, TRUE); } m_nTwipsLast = nTwips; }