EM_REPLACESEL

2.x

EM_REPLACESEL
wParam = 0;                                 /* not used, must be zero */
lParam = (LPARAM) (LPCSTR) lpszReplace;     /* address of new string  */

An application sends an EM_REPLACESEL message to replace the current selection in an edit control with the text specified by the lpszReplace parameter.

Parameters

lpszReplace

Value of lParam. Points to a null-terminated string containing the replacement text.

Return Value

This message does not return a value.

Comments

Use the EM_REPLACESEL message when you want to replace only a portion of the text in an edit control. If you want to replace all of the text, use the WM_SETTEXT message.

If there is no current selection, the replacement text is inserted at the current cursor location.

Example

This example sets the selection to the beginning of the edit control and inserts the string “C:\”:

SendDlgItemMessage(hdlg, ID_MYEDITCONTROL,
    EM_SETSEL, 0, MAKELONG(0, 0));
SendDlgItemMessage(hdlg, ID_MYEDITCONTROL,
    EM_REPLACESEL, 0, (LPARAM) ((LPCSTR) "C:\\"));

See Also

WM_SETTEXT