This documentation is archived and is not being maintained.

CRichEditCtrl::GetSel 

Retrieves the bounds of the current selection in this CRichEditCtrl object.


void GetSel(
   CHARRANGE& cr 
) const;
void GetSel(
   long& nStartChar,
   long& nEndChar 
) const;

Parameters

cr

Reference to a CHARRANGE structure to receive the bounds of the current selection.

nStartChar

Zero-based index of the first character in the current selection.

nEndChar

Zero-based index of the last character in the current selection.

The two forms of this function provide alternate ways to get the bounds for the selection. Brief descriptions of these forms follow:

  • GetSel( cr )   This form uses the CHARRANGE structure with its cpMin and cpMax members to return the bounds.

  • GetSel( nStartChar , nEndChar )   This form returns the bounds in the parameters nStartChar and nEndChar.

The selection includes everything if the beginning (cpMin or nStartChar) is 0 and the end (cpMax or nEndChar) is – 1.

For more information, see EM_EXGETSEL message and CHARRANGE structure in the Platform SDK.

// The pointer to my rich edit control.
extern CRichEditCtrl* pmyRichEditCtrl;

// Set the selection to be all characters after the current selection.
long nStartChar, nEndChar;

pmyRichEditCtrl->GetSel(nStartChar, nEndChar); 
pmyRichEditCtrl->SetSel(nEndChar, -1);
Show: