CRichEdit

Win32++

CRichEdit Class

Description

A rich edit control enables the user to enter, edit, print, and save text. The text can be assigned character and paragraph formatting, and can include embedded Component Object Model (COM) objects.

Refer to the documentation that ships with the Microsoft Windows Software Development Kit for more information on the use of rich edit controls.

CRichEdit Members

Construction

CRichEdit
CRichEdit();
Constructor for CRichEdit.

Attributes

GetCharPos
CPoint GetCharPos(long lChar) const;
Retrieves the client area coordinates of a specified character.
GetDefaultCharFormat
DWORD GetDefaultCharFormat(CHARFORMAT& cf) const;
GetDefaultCharFormat(CHARFORMAT2& cf) const;
Retrieves the current default character formatting attributes.
GetEventMask
GetEventMask() const;
Retrieves the event mask. The event mask specifies which notification messages the control sends to its parent window.
GetFirstVisibleLine
int GetFirstVisibleLine() const;
Gets the zero-based index of the uppermost visible line.
GetIRichEditOle
IRichEditOle* GetIRichEditOle() const;
Retrieves an IRichEditOle object that a client can use to access the rich edit control's Component Object Model (COM) functionality.
GetFirstVisibleLine
int GetFirstVisibleLine() const;
Returns the zero-based index of the first visible character in a single-line edit control or the zero-based index of the uppermost visible line in a multiline edit control.
GetLimitText
long GetLimitText() const;
Gets the current text limit for the edit control.
GetLine
int GetLine(int nIndex, LPTSTR lpszBuffer) const;
int GetLine(int nIndex, LPTSTR lpszBuffer, int nMaxLength) const;
Copies a line of text from the rich edit control and places it in the specified buffer. lpszBuffer is a pointer to the buffer that receives a copy of the line. Either specify nMaxLength, or set the first word of lpszBuffer to the size of the buffer in TCHARs.
GetLineCount
int GetLineCount() const;
Gets the number of lines in a multiline edit control.
GetModify
BOOL GetModify() const;
Retrieves a flag than indicates whether the contents of the edit control have been modified..
GetOptions
UINT GetOptions() const;
Retrieves the rich edit control options.
GetParaFormat
DWORD GetParaFormat(PARAFORMAT& pf) const;
DWORD GetParaFormat(PARAFORMAT2& pf) const;
Retrieves the paragraph formatting of the current selection.
GetRect
void GetRect(LPRECT lpRect) const;
Retrieves the formatting rectangle. The formatting rectangle is the limiting rectangle into which text can be drawn.
GetRedoName
UNDONAMEID GetRedoName() const;
Retrieves the type of the next action, if any, in the control's redo queue.
GetSel
void GetSel(CHARRANGE& cr) const;
void GetSel(long& nStartChar, long& nEndChar) const;
Retrieves the starting and ending character positions of the selection..
GetSelectionCharFormat
DWORD GetSelectionCharFormat(CHARFORMAT& cf) const;
DWORD GetSelectionCharFormat(CHARFORMAT2& cf) const;
Retrieves the character formatting attributes in the current selection.
GetSelectionType
WORD CRichEdit::GetSelectionType() const
Retrieves the type of contents in the current selection.
GetSelText
long GetSelText(LPSTR lpBuf) const;
CString GetSelText() const;
Gets the text of the current selection.
GetTextLength
long GetTextLength() const;
Retrieves the length of the text, in characters. Does not include the terminating null character.
GetTextLengthEx
long GetTextLengthEx(DWORD dwFlags, UINT uCodePage = -1) const;
Returns the number of TCHARs in the rich edit control, depending on the flags specified.
GetTextMode
UINT GetTextMode() const;
Retrieves the current text mode and undo level.
GetTextRange
int GetTextRange(int nFirst, int nLast, CString& refString) const;
Retrieves the specified range of text.
GetUndoName
UNDONAMEID GetUndoName() const;
Returns.
SetAutoURLDetect
BOOL SetAutoURLDetect(BOOL bEnable = TRUE) const;
Indicates if the auto URL detection is active.
SetBackgroundColor
COLORREF SetBackgroundColor(BOOL bSysColor, COLORREF cr) const;
Sets the background color.
SetDefaultCharFormat
BOOL SetDefaultCharFormat(CHARFORMAT& cf) const;
BOOL SetDefaultCharFormat(CHARFORMAT2& cf) const;
Sets the current default character formatting attributes.
SetEventMask
DWORD SetEventMask(DWORD dwEventMask) const;
Sets the event mask. The event mask specifies which notification messages the control sends to its parent window.
SetModify
void SetModify(BOOL bModified = TRUE) const;
Sets or clears the modification flag. The modification flag indicates whether the text has been modified.
SetOLECallback
BOOL SetOLECallback(IRichEditOleCallback* pCallback) const;
Sets the IRichEditOleCallback COM object.
SetOptions
void SetOptions(WORD wOp, DWORD dwFlags) const;
Sets the options.
Possible wOp values: ECOOP_SET, ECOOP_OR, ECOOP_AND, ECOOP_XOR
Possible dwFlags: ECO_AUTOWORDSELECTION, ECO_AUTOVSCROLL, ECO_AUTOHSCROLL, ECO_NOHIDESEL ECO_READONLY, ECO_WANTRETURN, ECO_SELECTIONBAR, ECO_VERTICAL
SetParaFormat
BOOL SetParaFormat(PARAFORMAT& pf) const;
BOOL SetParaFormat(PARAFORMAT2& pf) const;
Sets the paragraph formatting attributes in the current selection.
SetReadOnly
BOOL SetReadOnly(BOOL bReadOnly = TRUE) const;
Sets or removes the read-only style.
SetRect
void SetRect(LPCRECT lpRect) const;
Sets the formatting rectangle. The formatting rectangle is the limiting rectangle into which the control draws the text.
SetSel
void SetSel(long nStartChar, long nEndChar) const;
void SetSel(CHARRANGE& cr) const;
Selects a range of characters.
SetSelectionCharFormat
BOOL SetSelectionCharFormat(CHARFORMAT& cf) const;
BOOL SetSelectionCharFormat(CHARFORMAT2& cf) const;
Sets the character formatting attributes in the current selection.
SetTargetDevice
BOOL SetTargetDevice(HDC hDC, long lLineWidth) const;
BOOL SetTargetDevice(CDC& dc, long lLineWidth) const;
Sets the target output device and line width used for "what you see is what you get" (WYSIWYG) formatting.
SetTextMode
BOOL SetTextMode(UINT fMode) const;
Sets the text mode or undo level of the rich edit control. The message fails if the control contains text.
SetUndoLimit
UINT SetUndoLimit(UINT nLimit) const;
Sets the maximum number of actions that can stored in the undo queue. This member function fails if the control contains text.
SetWordCharFormat
BOOL SetWordCharFormat(CHARFORMAT& cf) const;
BOOL SetWordCharFormat(CHARFORMAT2& cf) const;
Sets the character formatting attributes in the current word.

Operations

CanPaste
BOOL CanPaste(UINT nFormat = 0) const;
Determines whether a rich edit control can paste a specified clipboard format.
CanRedo
BOOL CanRedo() const;
Determines whether there are any actions in the control redo queue.
CanUndo
BOOL CanUndo() const;
Determines whether there are any actions in an edit control's undo queue.
CharFromPos
int CharFromPos(CPoint pt) const;
Gets information about the character closest to a specified point in the client area of an edit control.
Clear
void Clear() const;
Delete (clear) the current selection
Copy
void Copy() const;
Copy the current selection to the clipboard in CF_TEXT format.
Cut
void Cut() const;
Delete (cut) the current selection, if any, in the edit control and copy the deleted text to the clipboard in CF_TEXT format.
DisplayBand
BOOL DisplayBand(LPRECT pDisplayRect) const;
Displays a portion of the contents of a rich edit control, as previously formatted for a device using the EM_FORMATRANGE message.
EmptyUndoBuffer
void EmptyUndoBuffer() const;
Resets the undo flag of the rich edit control. The undo flag is set whenever an operation within the edit control can be undone.
FindText
long FindText(DWORD dwFlags, FINDTEXTEX* pFindTextEx) const;
Finds text within the rich edit control.
FindWordBreak
DWORD FindWordBreak(UINT nCode, DWORD nStart) const;
Finds the next word break before or after the specified character position or retrieves information about the character at that position.
FormatRange
long FormatRange(FORMATRANGE* pfr, BOOL bDisplay = TRUE) const;
Formats a range of text in a rich edit control for a specific device (e.g. printer).
HideSelection
void HideSelection(BOOL bHide, BOOL bPerm) const;
Shows or hides the current selection.
LimitText
void LimitText(int nChars = 0) const;
Limits the amount of text a user can enter.
LineFromChar
long LineFromChar(long nIndex) const;
Determines which line contains the given character.
LineIndex
int LineIndex(int nLine = -1) const;
Retrieves the character index of a given line.
LineLength
int LineLength(int nLine = -1) const;
Retrieves the length of a given line.
LineScroll
void LineScroll(int nLines, int nChars = 0) const;
Scrolls the text.
Paste
void Paste() const;
Inserts the contents of the Clipboard.
PasteSpecial
void PasteSpecial(UINT nClipFormat, DWORD dwAspect = 0, HMETAFILE hMF = 0) const;
Inserts the contents of the Clipboard in the specified data format.
PosFromChar
CPoint PosFromChar(UINT nChar) const;
Retrieves the client area coordinates of a specified character.
Redo
BOOL Redo() const;
Redoes the next action in the control's redo queue.
ReplaceSel
void ReplaceSel(LPCTSTR lpszNewText, BOOL bCanUndo) const;
Replaces the current selection with specified text.
RequestResize
void RequestResize() const;
Forces the sending of a request resize notifications.
StopGroupTyping
void StopGroupTyping() const;
Stops the control from collecting additional typing actions into the current undo action. The control stores the next typing action, if any, into a new action in the undo queue.
StreamIn
long StreamIn(int nFormat, EDITSTREAM& es) const;
Replaces text with text from the specified input stream.
StreamOut
long StreamOut(int nFormat, EDITSTREAM& es) const;
Stores text into an output stream.
Undo
void Undo() const;
Reverses the last editing operation.

Overidables

PreRegisterClass
virtual void PreRegisterClass(WNDCLASS &wc);
Set the window class parameters before the window is created.
Base class Members

For base class members, refer to the members of CWnd.

Remarks

Like all common controls, the rich edit control requires a parent window. This parent window is often a dialog, but simple windows can also be the parent window for an edit control.

Summary Information

Header file rich_edit.h
Win32/64 support Yes
WinCE support No
Library required Comctl32.lib