EM_SETSEL

2.x

EM_SETSEL
wParam = (WPARAM) (UINT) fScroll;       /* flag for caret scrolling */
lParam = MAKELPARAM(ichStart, ichEnd);  /* start and end positions  */

An application sends an EM_SETSEL message to select a range of characters in an edit control.

Parameters

fScroll

Value of wParam. When this parameter is zero, the caret is scrolled into view. When this parameter is 1, the caret is not scrolled into view.

ichStart

Value of the low-order word of lParam. Specifies the starting position.

ichEnd

Value of the high-order word of lParam. Specifies the ending position.

Return Value

The return value is nonzero if the message is sent to an edit control.

Comments

If the ichStart parameter is 0 and the ichEnd parameter is –1, all the text in the edit control is selected. If ichStart is –1, any current selection is removed. The caret is placed at the end of the selection indicated by the greater of the two values ichEnd and ichStart.

Example

This example sends an EM_SETSEL message to select the entire contents of an edit control. It then sends a WM_CUT message to copy the contents of the edit control to the clipboard and then to delete the contents of the edit control.

SendDlgItemMessage(hdlg, ID_MYEDITCONTROL,
    EM_SETSEL, 0, MAKELONG(0, -1));
SendDlgItemMessage(hdlg, ID_MYEDITCONTROL,
    WM_CUT, 0, 0L);

See Also

EM_GETSEL, EM_REPLACESEL