Function Reference


_GUICtrlEdit_GetLineCount

Retrieves the number of lines

#include <GuiEdit.au3>
_GUICtrlEdit_GetLineCount ( $hWnd )

Parameters

$hWnd Control ID/Handle to the control

Return Value

Success: the total number of text lines.
Failure: 1.

Remarks

If the control has no text, the return value is 1.
The return value will never be less than 1.

The _GUICtrlEdit_GetLineCount() retrieves the total number of text lines, not just the number of lines that are currently visible.

If the Wordwrap feature is enabled, the number of lines can change when the dimensions of the editing window change.

Example

#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <GuiStatusBar.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"

        ; Create GUI
        $hGUI = GUICreate("Edit Get Line Count", 400, 300)
        $idEdit = GUICtrlCreateEdit("", 2, 2, 394, 268)
        $hStatusBar = _GUICtrlStatusBar_Create($hGUI, -1)
        GUISetState(@SW_SHOW)

        _GUICtrlEdit_SetText($idEdit, FileRead($sFile))
        _GUICtrlStatusBar_SetIcon($hStatusBar, 0, 97, "shell32.dll")
        _GUICtrlStatusBar_SetText($hStatusBar, @TAB & "Lines: " & _GUICtrlEdit_GetLineCount($idEdit))

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