Edit

Share via


EM_GETSEL message

Gets the starting and ending character positions (in TCHARs) of the current selection in an edit control. You can send this message to either an edit control or a rich edit control.

Parameters

wParam

A pointer to a DWORD value that receives the starting position of the selection. This parameter can be NULL.

lParam

A pointer to a DWORD value that receives the position of the first unselected character after the end of the selection. This parameter can be NULL.

Return value

The return value is a zero-based value with the starting position of the selection in the LOWORD and the position of the first TCHAR after the last selected TCHAR in the HIWORD. If either of these values exceeds 65,535, the return value is -1.

It is better to use the values returned in wParam and lParam because they are full 32-bit values.

Remarks

If there is no selection, the starting and ending values are both the position of the caret.

Rich edit controls: You can also use the EM_EXGETSEL message to retrieve the same information. EM_EXGETSEL also returns starting and ending character positions as 32-bit values.

Rich Edit: Supported in Microsoft Rich Edit 1.0 and later. For information about the compatibility of rich edit versions with the various system versions, see About Rich Edit Controls.

Requirements

Requirement Value
Minimum supported client
Windows Vista [desktop apps only]
Minimum supported server
Windows Server 2003 [desktop apps only]
Header
Winuser.h (include Windows.h)

See also

Reference

EM_EXGETSEL

EM_SETSEL