Share via


CRichEditCtrl::ReplaceSel

Replaces the current selection in this CRichEditCtrl object with the specified text.

void ReplaceSel(
   LPCTSTR lpszNewText,
   BOOL bCanUndo = FALSE 
);

Parameters

  • lpszNewText
    Pointer to a null-terminated string containing the replacement text.

  • bCanUndo
    To specify that this function can be undone, set the value of this parameter to TRUE. The default value is FALSE.

Remarks

To replace all the text in this CRichEditCtrl object, use CWnd::SetWindowText.

If there is no current selection, the replacement text is inserted at the insertion point, that is, the current caret location.

This function will format the inserted text with the existing character formatting. When replacing the entire range of text (by calling SetSel(0,-1) before calling ReplaceSel), there is an end of paragraph character that retains the previous paragraph's formatting, which in inherited by the newly inserted text.

For more information, see EM_REPLACESEL in the Windows SDK.

Example

See the example for LineIndex.

Requirements

Header: afxcmn.h

See Also

Reference

CRichEditCtrl Class

Hierarchy Chart

CRichEditCtrl::CanUndo

CRichEditCtrl::Undo

CWnd::SetWindowText

Other Resources

CRichEditCtrl Members