CTextRange2.SetRangemethod
Adjusts the range endpoints to the specified values.
Syntax
FUNCTION SetRange (BYVAL cpAnchor AS LONG, BYVAL cpActive AS LONG) AS HRESULT
Parameters
| Name | Description | |
|---|---|---|
cpAnchor | The character position for the anchor end of the range. | |
cpActive | The character position for the active end of the range. |
Return value
If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
Description
Adjusts the range endpoints to the specified values.
Remarks
This method sets the range's start position to min(cpActive, cpAnchor), and the end position to max(cpActive, cpAnchor). If the range is a nondegenerate selection, cpAnchor is the active end, and cpAnchor is the anchor end. If the range is a degenerate selection, the selection is displayed at the start of the line, rather than at the end of the previous line.
This method removes any other subranges this range may have. To preserve the current subranges, use SetActiveSubrange.
If the text range is a selection, you can set the attributes of the selection by using the SetFlags method.
Reference
- Defined in AfxNova/CTextRange2.inc:417
- Documented in Windows/WIndows Controls/RichEdit/CTextRange2 Class.md
- Topic: CTextRange2 Class