void CMSOffice2007DemoView::OnSelChange(NMHDR* pNMHDR, LRESULT* pResult) { CRichEditView::OnSelChange(pNMHDR, pResult); if (GetFocus ()->GetSafeHwnd () != GetSafeHwnd()) { return; } CMainFrame* pMainFrame = ((CMainFrame*) GetTopLevelFrame()); ASSERT_VALID(pMainFrame); UINT uiCategoryID = 0; CMSOffice2007DemoCntrItem* pItem = (CMSOffice2007DemoCntrItem*) GetSelectedItem(); if (pItem != NULL) { uiCategoryID = pItem->m_uiCategoryID; } pMainFrame->SetRibbonContextCategory(uiCategoryID); SyncFont(); }
void CMSOffice2007DemoView::OnInsertPicture() { WPD_CHARFORMAT cf = GetCharFormatSelection(); InsertBitmap(IDB_PICTURE); SetCharFormat (cf); SyncFont (); }
void CMSOffice2007DemoView::OnInsertTable() { WPD_CHARFORMAT cf = GetCharFormatSelection(); InsertBitmap(IDB_TABLE); SetCharFormat (cf); SyncFont (); }
void CBCGPMSOffice2007DemoView::OnInitialUpdate () { CRichEditView::OnInitialUpdate(); SendMessage (EM_SHOWSCROLLBAR, SB_HORZ, FALSE); SendMessage (EM_SHOWSCROLLBAR, SB_VERT, FALSE); GetRichEditCtrl ().SetEventMask (GetRichEditCtrl ().GetEventMask() | (ENM_REQUESTRESIZE | ENM_SCROLL)); CScrollBar* pScrollBar = ((CMainFrame*) GetTopLevelFrame ())->GetScrollBar (); if (pScrollBar->GetSafeHwnd () != NULL && GetRichEditCtrl().GetTextLength () == 0) { ASSERT_VALID (pScrollBar); pScrollBar->EnableScrollBar (ESB_DISABLE_BOTH); } // Set the printing margins (720 twips = 1/2 inch). SetMargins(CRect(720, 720, 720, 720)); CCharFormat cf; GetDefaultFont (cf); SetCharFormat (cf); SyncFont (); }
// /// Restores the original GDI font object to this DC. // void TPrintPreviewDC::RestoreFont() { PrnDC.RestoreFont(); PrnFont = (HFONT)PrnDC.GetCurrentObject(OBJ_FONT); TPrintDC::RestoreFont(); SyncFont(); }
void CBCGPMSOffice2007DemoView::OnFontGrow() { WPD_CHARFORMAT cf = GetCharFormatSelection (); cf.yHeight += 20; SetCharFormat (cf); SyncFont (); }
void CBCGPMSOffice2007DemoView::OnFontShrink() { WPD_CHARFORMAT cf = GetCharFormatSelection (); if (cf.yHeight <= 20) { return; } cf.yHeight -= 20; SetCharFormat (cf); SyncFont (); }
void CMSOffice2007DemoView::OnInitialUpdate() { CRichEditView::OnInitialUpdate(); // Set the printing margins(720 twips = 1/2 inch). SetMargins(CRect(720, 720, 720, 720)); CCharFormat cf; GetDefaultFont(cf); SetCharFormat(cf); SyncFont(); }
void CMSOffice2007DemoView::OnInsertTableGallery() { if (CRibbonTableButton::GetRows() > 0 && CRibbonTableButton::GetColumns() > 0) { CString str; str.Format(_T("Demo: insert %dx%d table"), CRibbonTableButton::GetColumns(), CRibbonTableButton::GetRows()); MessageBox(str); WPD_CHARFORMAT cf = GetCharFormatSelection(); InsertBitmap(IDB_TABLE); SetCharFormat (cf); SyncFont (); } }
void CMSOffice2007DemoView::OnFontDialog() { CRichEditView::OnFormatFont(); SyncFont(); }
BOOL CBCGPMSOffice2007DemoView::InsertBitmap (UINT uiBmpResID) { CWaitCursor wait; CBitmap bmp; if (!bmp.LoadBitmap(uiBmpResID)) { return FALSE; } COleDataSource* pDataSrc = new COleDataSource; COleDataObject* pData = new COleDataObject; CBCGPMSOffice2007DemoCntrItem* pItem = NULL; TRY { WPD_CHARFORMAT cf = GetCharFormatSelection(); STGMEDIUM stgm; stgm.hGlobal = bmp.GetSafeHandle(); stgm.tymed = TYMED_GDI; stgm.pUnkForRelease = NULL; pDataSrc->CacheData (CF_BITMAP, &stgm); LPDATAOBJECT lpdata; if (FAILED (pDataSrc->m_xDataObject.QueryInterface (IID_IDataObject, (LPVOID FAR*) &lpdata))) { AfxThrowUserException(); } pData->Attach (lpdata); CBCGPMSOffice2007DemoDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); pItem = new CBCGPMSOffice2007DemoCntrItem (NULL, pDoc); ASSERT_VALID(pItem); if (!pItem->CreateStaticFromData (pData)) { AfxThrowUserException(); } pItem->m_uiCategoryID = uiBmpResID; InsertItem (pItem); pDoc->UpdateAllViews (this); SetCharFormat (cf); SyncFont (); } CATCH(CException, e) { if (pItem != NULL) { ASSERT_VALID(pItem); pItem->Delete (); } delete pData; delete pDataSrc; return FALSE; } END_CATCH delete pData; delete pDataSrc; CMainFrame* pMainFrame = ((CMainFrame*) GetTopLevelFrame ()); ASSERT_VALID (pMainFrame); pMainFrame->ActivateRibbonContextCategory (uiBmpResID); return TRUE; }