Freigeben über


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.

Remarks

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 Windows SDK.

Example

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

m_myRichEditCtrl.GetSel(nStartChar, nEndChar); 
m_myRichEditCtrl.SetSel(nEndChar, -1);

Requirements

Header: afxcmn.h

See Also

Reference

CRichEditCtrl Class

Hierarchy Chart

CRichEditCtrl::SetSel

CRichEditCtrl::GetSelText

CRichEditCtrl::GetParaFormat

CRichEditCtrl::GetSelectionCharFormat

Other Resources

CRichEditCtrl Members