Function Reference


_GUICtrlEdit_LineIndex

Retrieves the character index of the first character of a specified line

#include <GuiEdit.au3>
_GUICtrlEdit_LineIndex ( $hWnd [, $iIndex = -1] )

Parameters

$hWnd Control ID/Handle to the control
$iIndex [optional] Specifies the 0-based line number

Return Value

Success: the character index of the line specified in the $iIndex parameter.
Failure: –1 if the specified line number is greater than the number of lines in the edit control.

Remarks

$iIndex = –1 specifies the current line number (the line that contains the caret).

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <GuiStatusBar.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
        Local $hStatusBar, $idEdit, $hGUI
        Local $sWow64 = ""
        If @AutoItX64 Then $sWow64 = "\Wow6432Node"
        Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\include\_ReadMe_.txt"
        Local $aPartRightSide[2] = [378, -1], $iRandom

        ; Create GUI
        $hGUI = GUICreate("Edit Line Index", 400, 300)
        $idEdit = GUICtrlCreateEdit("", 2, 2, 394, 268, BitOR($ES_WANTRETURN, $WS_VSCROLL))
        $hStatusBar = _GUICtrlStatusBar_Create($hGUI, $aPartRightSide)
        _GUICtrlStatusBar_SetIcon($hStatusBar, 1, 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))

        ; Line Index
        $iRandom = Random(0, _GUICtrlEdit_GetLineCount($idEdit) - 1, 1)
        _GUICtrlStatusBar_SetText($hStatusBar, "Char Index: " & _GUICtrlEdit_LineIndex($idEdit, $iRandom) & " from Line: " & $iRandom)

        ; Loop until the user exits.
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE
        GUIDelete()
EndFunc   ;==>Example