CRichEdit.GetSelmethod
Retrieves the starting and ending character positions of the current selection in a rich edit control.
Syntax
FUNCTION GetSel (BYVAL hRichEdit AS HWND, BYVAL pdwStartPos AS DWORD PTR, BYVAL pdwEndPos AS DWORD PTR) AS LONG
Parameters
| Name | Description | |
|---|---|---|
hRichEdit | The handle of the rich edit control. | |
pdwStartPos | A pointer to a DWORD value that receives the starting position of the selection. This parameter can be NULL. | |
pdwEndPos | 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 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 pdwStartPos and pdwEndPos because they are full 32-bit values.
Description
Retrieves 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 EM_EXGETSEL message to retrieve the same information. EM_EXGETSEL also returns starting and ending character positions as 32-bit values. A combination of the use of EM_EXGETSEL and EM_GETSELTEXT are used in the GetSelText function to retrieve the selected text as a DWSTRING.
Reference
- Defined in AfxNova/CRichEdit.inc:631
- Documented in Windows/WIndows Controls/CRichEdit Class.md
- Topic: CRichEdit Class