![]() ![]() |
||
RTF File Showing and Printing E-XD++ supports showing, instant editing, drawing, and WYSIWYG (What You See Is What You Get) printing for RTF documents. E-XD++ contains tens of operations for RTF document, such as reading RTF document, copying/pasting content in RTF document, Setting fonts/alignments for content in RTF document, etc, as shown below:
Steps: 1. Create font name and font size selection combobox at toolbar: data.nComboID = IDC_COMBO_FONTNAME; 2. Change font name and size with rich text shape: void CRichTextView::OnFontFaceChange() { CMainFrame *pParent = STATIC_DOWNCAST(CMainFrame,AfxGetMainWnd()); ASSERT_VALID(pParent); if(pParent->IsWindowVisible()) { int nCur = pParent->pFontNameBox->GetCurSel(); if(nCur != -1) { CString strFontName; pParent->pFontNameBox->GetLBText(nCur,strFontName); if (m_listSelectComp.GetCount() > 0) { CFODrawShape *pObj = GetCurrentSelectShape(); ASSERT(pObj); if (pObj->IsKindOf(RUNTIME_CLASS(CFOPRichEditShape))) { CFOPRichEditShape *pRichEdit = static_cast<CFOPRichEditShape *>(pObj); ASSERT(pRichEdit); pRichEdit->SetCurrentFontName(strFontName); } else { GetCurrentModel()->ChangeShapesStringProp(&m_listSelectComp,strFontName,P_ID_FONT_FACENAME); } GetCurrentModel()->SetModifiedFlag(); CFOWndDC dc(this); POSITION pos = m_listSelectComp.GetHeadPosition(); while (pos != NULL) { ((CFODrawShape*)m_listSelectComp.GetNext(pos))->AdjustTextBoxSize(&dc); } UpdateShapes(&m_listSelectComp); } } } } void CRichTextView::OnUpdateFontFacename(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->Enable(GetCurrentModel()->IsDesignMode()); CString strFaceName = _T(""); if (m_listSelectComp.GetCount() > 0) { CFODrawShape *pShape = GetCurrentSelectShape(); ASSERT(pShape); if (pShape->IsKindOf(RUNTIME_CLASS(CFOPRichEditShape))) { CFOPRichEditShape *pRichEdit = static_cast<CFOPRichEditShape *>(pShape); ASSERT(pRichEdit); strFaceName = pRichEdit->GetCurrentFontName(); } else { strFaceName = pShape->GetFaceName(); } } CMainFrame *pParent = STATIC_DOWNCAST(CMainFrame,AfxGetMainWnd()); ASSERT_VALID(pParent); if (pParent->IsWindowVisible()) { CString strFontName; pParent->pFontNameBox->GetWindowText(strFontName); if (strFontName == strFaceName) return; if (CB_ERR == pParent->pFontNameBox->SelectString(-1, strFaceName)) TRACE(_T("the font name can't find.")); } } void CRichTextView::OnFontSizeChange() { CMainFrame *pParent = STATIC_DOWNCAST(CMainFrame,AfxGetMainWnd()); ASSERT_VALID(pParent); if(pParent->IsWindowVisible()) { int nCur = pParent->pFontSizeBox->GetCurSel(); if(nCur != -1) { CString strSize; pParent->pFontSizeBox->GetLBText(nCur,strSize); if (m_listSelectComp.GetCount() > 0) { CFODrawShape *pObj = GetCurrentSelectShape(); ASSERT(pObj); if (pObj->IsKindOf(RUNTIME_CLASS(CFOPRichEditShape))) { CFOPRichEditShape *pRichEdit = static_cast<CFOPRichEditShape *>(pObj); ASSERT(pRichEdit); pRichEdit->SetCurrentFontSize(atoi(strSize)); } else { GetCurrentModel()->ChangeShapesIntProp(&m_listSelectComp,atoi(strSize),P_ID_FONT_POINTSIZE); } GetCurrentModel()->SetModifiedFlag(); CFOWndDC dc(this); POSITION pos = m_listSelectComp.GetHeadPosition(); while(pos != NULL){ ((CFODrawShape *)m_listSelectComp.GetNext(pos))->AdjustTextBoxSize(&dc); } UpdateShapes(&m_listSelectComp); } } } } void CRichTextView::OnUpdateFontTypesize(CCmdUI* pCmdUI) { // TODO: Add your command update UI handler code here pCmdUI->Enable(GetCurrentModel()->IsDesignMode()); CMainFrame *pParent = STATIC_DOWNCAST(CMainFrame,AfxGetMainWnd()); ASSERT_VALID(pParent); if (FALSE == pParent->IsWindowVisible()) return; int nFontSize = 0; if (m_listSelectComp.GetCount() > 0) { CFODrawShape *pShape = GetCurrentSelectShape(); ASSERT(pShape); if (pShape->IsKindOf(RUNTIME_CLASS(CFOPRichEditShape))) { CFOPRichEditShape *pRichEdit = static_cast<CFOPRichEditShape *>(pShape); ASSERT(pRichEdit); nFontSize = pRichEdit->GetCurrentFontSize(); } else { nFontSize = pShape->GetPointSize(); } } CString strFaceSize = _T(""); strFaceSize.Format(_T("%d"), nFontSize); CString strFontSize = _T(""); pParent->pFontSizeBox->GetWindowText(strFontSize); if (strFontSize == strFaceSize) return; if (CB_ERR == pParent->pFontSizeBox->SelectString(-1, strFaceSize)) TRACE(_T("the font size can't find.")); } |
Copyright ?1998-2007 UCanCode.Net Software, all rights reserved.
Other product and company names herein may be the trademarks of their respective owners.
Please direct your questions or comments to webmaster@ucancode.com