Freigeben über


IVsTextView.GetSelection(Int32, Int32, Int32, Int32) Method

Definition

Returns the text span corresponding to the current selection, if there is one.

public:
 int GetSelection([Runtime::InteropServices::Out] int % piAnchorLine, [Runtime::InteropServices::Out] int % piAnchorCol, [Runtime::InteropServices::Out] int % piEndLine, [Runtime::InteropServices::Out] int % piEndCol);
int GetSelection([Runtime::InteropServices::Out] int & piAnchorLine, [Runtime::InteropServices::Out] int & piAnchorCol, [Runtime::InteropServices::Out] int & piEndLine, [Runtime::InteropServices::Out] int & piEndCol);
public int GetSelection (out int piAnchorLine, out int piAnchorCol, out int piEndLine, out int piEndCol);
abstract member GetSelection : int * int * int * int -> int
Public Function GetSelection (ByRef piAnchorLine As Integer, ByRef piAnchorCol As Integer, ByRef piEndLine As Integer, ByRef piEndCol As Integer) As Integer

Parameters

piAnchorLine
Int32

[out] Anchor line position for the selection. Based on user selection, this value is not necessarily the upper line in the selection.

piAnchorCol
Int32

[out] Anchor column position for the selection. Based on user selection, this value is not necessarily the upper, left column position in the selection. Viewcol coordinates may include virtual space.

piEndLine
Int32

[out] End line position for the selection. Based on user selection, this value is not necessarily the lower line in the selection.

piEndCol
Int32

[out] End column position for the selection. Based on user selection, this value is not necessarily the lower, right column position in the selection. Viewcol coordinates may include virtual space.

Returns

If the method succeeds, it returns S_OK. If it fails, it returns an error code.

Remarks

COM Signature

From textmgr.idl:

HRESULT IVsTextView::GetSelection(  
   [out] long *piAnchorLine,  
   [out] ViewCol *piAnchorCol,  
   [out] long *piEndLine,  
   [out] ViewCol *piEndCol  
);  

The parameters for GetSelection can be null if they are not needed to determine the selection. To return this information in a TextSpan structure, call the GetSelectionSpan method.

Note

The anchor position is not always the left or upper position in the text view. For example, in a span of 10 lines, the user may anchor their selection in line 10 and end their selection in line 1, thus reversing the expected anchor/line order.

Applies to