Help Center

CRichEdit.ReplaceSelmethod

Replaces the current selection in a rich edit control with the specified text.

Windowsmethoddocumented

Syntax

SUB ReplaceSel (BYVAL hRichEdit AS HWND, BYVAL bCanBeUndone AS LONG, BYVAL pwszText AS WSTRING PTR)

Parameters

NameDescription
hRichEditThe handle of the rich edit control.
bCanBeUndoneSpecifies whether the replacement operation can be undone. If this is TRUE, the operation can be undone. If this is FALSE, the operation cannot be undone.
pwszTextA pointer to a null-terminated string containing the replacement text.

Description

Replaces the current selection in a rich edit control with the specified text.

Remarks

Use the ReplaceSel message to replace only a portion of the text in an edit control. To replace all of the text, use the SetText message or the SetWindowText Windows API function.

If there is no selection, the replacement text is inserted at the caret.

In a rich edit control, the replacement text takes the formatting of the character at the caret or, if there is a selection, of the first character in the selection.

Reference

  • Defined in AfxNova/CRichEdit.inc:897
  • Documented in Windows/WIndows Controls/CRichEdit Class.md
  • Topic: CRichEdit Class