Selects a range of characters
#include <GuiEdit.au3>
_GUICtrlEdit_SetSel ( $hWnd, $iStart, $iEnd )
$hWnd | Control ID/Handle to the control |
$iStart | Specifies the starting character position of the selection. |
$iEnd | Specifies the ending character position of the selection. |
The start value can be greater than the end value.
The lower of the two values specifies the character position of the first character in the selection.
The higher value specifies the position of the first character beyond the selection.
The start value is the anchor point of the selection, and the end value is the active end.
If the user uses the SHIFT key to adjust the size of the selection, the active end can move but the anchor point remains the same.
If the $iStart is 0 and the $iEnd is –1, all the text in the edit control is selected.
If the $iStart is –1, any current selection is deselected.
The control displays a flashing caret at the $iEnd position regardless of the relative values of $iStart and $iEnd.
_GUICtrlEdit_GetSel, _GUICtrlEdit_ReplaceSel
#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>
Example()
Func Example()
Local $sWow64 = ""
If @AutoItX64 Then $sWow64 = "\Wow6432Node"
Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\include\_ReadMe_.txt"
Local $aPartRightSide[3] = [190, 378, -1], $aSel
; Create GUI
Local $hGUI = GUICreate("Edit Get/Set Sel (v" & @AutoItVersion & ")", 400, 300)
Local $idEdit = GUICtrlCreateEdit("", 2, 2, 394, 268, BitOR($ES_WANTRETURN, $WS_VSCROLL))
Local $hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aPartRightSide)
_GUICtrlStatusBar_SetIcon($hStatusBar, 2, 97, "shell32.dll")
GUISetState(@SW_SHOW)
; Set Margins
_GUICtrlEdit_SetMargins($idEdit, BitOR($EC_LEFTMARGIN, $EC_RIGHTMARGIN), 10, 10)
; Set Text
_GUICtrlEdit_SetText($idEdit, FileRead($sFile))
; Set Sel
_GUICtrlEdit_SetSel($idEdit, 15, 20)
; Get Sel
$aSel = _GUICtrlEdit_GetSel($idEdit)
_GUICtrlStatusBar_SetText($hStatusBar, "Start: " & $aSel[0])
_GUICtrlStatusBar_SetText($hStatusBar, "End: " & $aSel[1], 1)
; Loop until the user exits.
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>Example