Help Center

CRichEditCtx.GetSelmethod

Gets the starting and ending character positions of the current selection in a rich edit control.

Windowsmethoddocumented

Syntax

FUNCTION GetSel OVERLOAD (BYREF dwStartPos AS DWORD, BYREF dwEndPos AS DWORD) AS LONG
FUNCTION GetSel OVERLOAD () AS .POINTL

Parameters

NameDescription
dwStartPosA DWORD variable that receives the starting position of the selection. This parameter can be NULL.
dwEndPosA DWORD variable 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 character after the last selected character 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 dwStartPos and dwEndPos because they are full 32-bit values.

The second overloaded method returns a POINTL structure. The x and y members of this structure receive the starting and ending positions of the selection.

Description

Gets the starting and ending character positions of the current selection in a rich edit control.

Remarks

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

You can also use the ExtGetSel method to retrieve the same information. ExtGetSel also returns starting and ending character positions as 32-bit values. A combination of the use of ExtGetSel and GetSelText are used in the GetSelText method to retrieve the selected text as a DWSTRING.

Reference

  • Defined in AfxNova/CRichEditCtx.inc:2203
  • Documented in Windows/WIndows Controls/RichEdit/CRichEditCtx Class.md
  • Topic: CRichEditCtx Class