/***********************************************************************/ /* Copyright (C) 2002 Definitive Solutions, Inc. All Rights Reserved. */ /* THIS COMPUTER PROGRAM IS PROPRIETARY AND CONFIDENTIAL TO DEFINITIVE */ /* SOLUTIONS, INC. AND ITS LICENSORS AND CONTAINS TRADE SECRETS OF */ /* DEFINITIVE SOLUTIONS, INC. THAT ARE PROVIDED PURSUANT TO A WRITTEN */ /* AGREEMENT CONTAINING RESTRICTIONS ON USE AND DISCLOSURE. ANY USE, */ /* REPRODUCTION, OR TRANSFER EXCEPT AS PROVIDED IN SUCH AGREEMENT */ /* IS STRICTLY PROHIBITED. */ /***********************************************************************/ ///////////////////////////////////////////////////////////////////////////// // How to add this class to your application. // // Add MyRichEditCtrl.cpp, MyRichEditCtrl.h, MyRichEditCtrlResource.h, // MyRichEditCtrl.rc2, and MyRichEditCtrl.bmp to your project in the usual // folders. // // Add this line to the top of your RC2 file: // #include "MyRichEditCtrlResource.h" // MyRichEditCtrl resources. // // Add this line to the end of your RC2 file: // #include "MyRichEditCtrl.rc2" // MyRichEditCtrl resources. // // By default, this class does not use its FormatBar. To enable it, the // class (probably a view or dialog) that contains this rich edit control // should create a FormatBar object. Then, it should tell the FormatBar // about the MyRichEditCtrl it is to serve, by calling SetRichEditCtrl(). ///////////////////////////////////////////////////////////////////////////// #if !defined(AFX_MYRICHEDITCTRL_H__1C3295E3_C316_11D5_8A64_00B0D0529ED2__INCLUDED_) #define AFX_MYRICHEDITCTRL_H__1C3295E3_C316_11D5_8A64_00B0D0529ED2__INCLUDED_ #pragma once ///////////////////////////////////////////////////////////////////////////// // Defines // Note that these are all floats, to avoid interger truncation. #define MM_PER_TWIP ( MM_PER_INCH / TWIPS_PER_INCH ) #define MM_PER_INCH 25.4 #define TWIPS_PER_POINT 20.0 #define POINTS_PER_INCH 72.0 #define TWIPS_PER_INCH ( TWIPS_PER_POINT * POINTS_PER_INCH ) // WM_APP messages. #define WM_APP_NOTES_UPDATE_UI (WM_APP + 1) ///////////////////////////////////////////////////////////////////////////// // MyRichEditCtrl // Declare the class depending on this file is in an EXE project or a DLL one. class #ifdef _WINDLL AFX_EXT_CLASS #endif MyRichEditCtrl : public CRichEditCtrl { // Construction. public: MyRichEditCtrl(); virtual ~MyRichEditCtrl(); // Operations. public: // General functions. bool AppendFormattedText(const CString& s, CHARFORMAT& cf); bool AppendFromClipboard(CString& sClipboard, int nTwips); void ScrollToBottom(); void SetRTF(const CString& sRTF); CString GetRTF(); // Printing. void Print(bool bReallyPrint, CDC* pDC, CPrintInfo* pInfo, CRect* prcClip, LONG& lnNextCharToPrint); void PrintPreview(HDC hdcPrinter, HDC hdcScreen, LONG& lnNextCharToPrint); HENHMETAFILE RTFToEMF(HDC hdcPrinter, int nStartChar, int* pnEndChar); // Fonts. long GetSelectionFontSize(bool& bConsistent) const; CString GetSelectionFontName(bool& bConsistent) const; void SetFontSize(int nPointSize); void SetFontName(const CString& sFontName); void SelectColor(); // Paragraph. bool ParagraphIsBulleted() const; void SetParagraphBulleted(); bool ParagraphIsNumbered() const; void CycleParagraphNumbered(); PARAFORMAT GetParagraphFormat() const; bool ParagraphIsRight() const; bool ParagraphIsLeft() const; bool ParagraphIsCenter() const; void SetParagraphRight(); void SetParagraphLeft(); void SetParagraphCenter(); void IndentParagraph(); void OutdentParagraph(); // Character. bool SelectionIsBold() const; bool SelectionIsItalic() const; bool SelectionIsUnderline() const; void SetSelectionBold(); void SetSelectionItalic(); void SetSelectionUnderline(); void SetCharStyle(int nMask, int nStyle, int nStart, int nEnd); CHARFORMAT GetCharFormat(DWORD dwMask = CFM_COLOR | CFM_FACE | CFM_SIZE | CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE) const; void SetDefaultFormat(const CString& sFontName, int nFontSizePoints); // See: Microsoft KB Article Q280447: "BUG: Text from a Rich Edit Control // Is Truncated During Dialog Data Exchange (DDX)". Note that it's not // virtual, so this fix won't work polymorphically. void SetWindowText(LPCTSTR lpszString); //{{AFX_VIRTUAL(MyRichEditCtrl) //}}AFX_VIRTUAL // Generated message map functions. protected: //{{AFX_MSG(MyRichEditCtrl) afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu); afx_msg void OnEditCopy(); afx_msg void OnEditCut(); afx_msg void OnEditPaste(); afx_msg void OnEditSelectAll(); afx_msg void OnRButtonUp(UINT nFlags, CPoint point); //}}AFX_MSG DECLARE_MESSAGE_MAP() // Implementation. private: static DWORD CALLBACK CBStreamIn(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb); static DWORD CALLBACK CBStreamOut(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG* pcb); }; ///////////////////////////////////////////////////////////////////////////// // FormatBar window class FormatBar : public CToolBar { // Construction. public: FormatBar(); virtual ~FormatBar(); // Operations. public: //{{AFX_VIRTUAL(FormatBar) //}}AFX_VIRTUAL // Generated message map functions. protected: //{{AFX_MSG(FormatBar) afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); afx_msg void OnUpdateButton(CCmdUI* pCmdUI); //}}AFX_MSG afx_msg void OnSelectFontName(); afx_msg void OnSelectFontSize(); afx_msg void OnClick(); DECLARE_MESSAGE_MAP() // Interface. public: void SetRichEditCtrl(MyRichEditCtrl* pMyRichEditCtrl); // Imlementation. protected: LRESULT OnUpdateUI(WPARAM wParam, LPARAM lParam); static int CALLBACK EnumFontFamProc(ENUMLOGFONT *lpelf, NEWTEXTMETRIC *lpntm, int nFontType, LPARAM lParam); // Data. private: CComboBox m_comboFontName; // Holds the font names. CComboBox m_comboFontSize; // Holds the font sizes. MyRichEditCtrl* m_pMyRichEditCtrl; // Rich edit. }; //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_MYRICHEDITCTRL_H__1C3295E3_C316_11D5_8A64_00B0D0529ED2__INCLUDED_)