Export (0) Print
Expand All
Expand Minimize

CRichEditCtrl::ReplaceSel

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

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

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.

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.

See the example for LineIndex.

Header: afxcmn.h

Show:
© 2014 Microsoft