method Edit.GetSelection (SelStartLine as Variant, SelStartPos as Variant, SelEndLine as Variant, SelEndPos as Variant)
Retrieves the coordinates of the selection.

TypeDescription
SelStartLine as Variant A long expression that indicates the index of the line where the selection starts.
SelStartPos as Variant A long expression that indicates the index of the character in the line where the selection starts.
SelEndLine as Variant A long expression that indicates the index of the line where the selection ends.
SelEndPos as Variant A long expression that indicates the index of the character in the line where the selection ends.
Use the GetSelection method to retrieve the coordinates of the selected text. Use the SelLenght property to return or set the number of characters selected. Use the SetSelection method to select a text giving start and end coordinates. The SelText property returns or sets the string containing the currently selected text; consists of a zero-length string ("") if no characters are selected. Use the CaretLine and CaretPos coordinates to determine the coordinates of the caret/cursor in the control. The control fires SelChange event when selection is changed or when the cursor is moved.

The following VB sample prints the coordinates of the selection when the user changes the selection:

Private Sub Edit1_SelChange()
    Dim sl, sp, el, ep
    With Edit1
        .GetSelection sl, sp, el, ep
    End With
    Debug.Print "The selection starts at (" & sl & "," & sp & ") and ends at (" & el & "," & ep & ")"
End Sub

The following VFP sample prints the coordinates of the selection when the user changes the selection:

*** ActiveX Control Event ***

local SelStartLine, SelStartPos, SelEndLine, SelEndPos

SelStartLine = 0
SelStartPos = 0
SelEndLine = 0
SelEndPos = 0

With thisform.Edit1
        .GetSelection( @SelStartLine, @SelStartPos , @SelEndLine, @SelEndPos)
EndWith

wait window nowait Str(SelStartLine) + Str(SelStartPos) + Str(SelEndLine) + Str(SelEndPos) 

The following C++ sample prints the coordinates of the selection when the user changes the selection:

static long V2I( VARIANT* pv, long nDefault = 0 )
{
	if ( pv )
	{
		if ( pv->vt == VT_ERROR )
			return nDefault;

		COleVariant vt;
		vt.ChangeType( VT_I4, pv );
		return V_I4( &vt );
	}
	return nDefault;
}

void OnSelChangeEdit1() 
{
	COleVariant vtSelStartLine, vtSelStartPos, vtSelEndLine, vtSelEndPos;
	m_edit.GetSelection( &vtSelStartLine, &vtSelStartPos, &vtSelEndLine, &vtSelEndPos );

	TCHAR szOutput[1024];
	wsprintf( szOutput, "The selection starts at (%i,%i) and ends at (%i,%i)\n", V2I(&vtSelStartLine), V2I( &vtSelStartPos ), V2I(&vtSelEndLine), V2I( &vtSelEndPos ) );
	OutputDebugString( szOutput );
}

The following VB.NET sample prints the coordinates of the selection:

Private Sub AxEdit1_SelChange(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxEdit1.SelChange
    With AxEdit1
        Dim sl As Object = 0, sp As Object = 0, el As Object = 0, ep As Object = 0
        .GetSelection(sl, sp, el, ep)
        Debug.WriteLine("Selection: " & sl.ToString() & " " & sp.ToString() & " " & el.ToString() & " " & ep.ToString())
    End With
End Sub

The following C# sample prints the coordinates of the selection:

private void axEdit1_SelChange(object sender, EventArgs e)
{
	object sl = 0, sp = 0, el = 0, ep = 0;
	axEdit1.GetSelection(out sl, out sp, out el, out ep);
	System.Diagnostics.Debug.WriteLine("Selection: " + sl.ToString() + " " + sp.ToString() + " " + el.ToString() + " " + ep.ToString());
}

The following VFP sample prints the coordinates of the selection :

*** ActiveX Control Event ***

with thisform.Edit1.Object
	local sl, sp, el, ep
	sl = 0
	sp = 0
	el = 0
	ep = 0
	.GetSelection( @sl, @sp, @el, @ep )
endwith