Very nice script.
Still works after small change:
AdlibEnable >>> AdlibRegister
I also make some celanup.
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7
#include <GUIConstants.au3>
#include <GuiEdit.au3>
#include <Misc.au3>
Global $g_iMainLineCount = 0 ; Keep a global count so we can check if it has changed
Global $_idEdit_Num , $_idEdit_Main
Example()
Func Example()
Local $hGui = GUICreate("Example", 123, 176, 415, 239, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_SYSMENU, $WS_CAPTION, $WS_OVERLAPPEDWINDOW, $WS_TILEDWINDOW, $WS_POPUP, $WS_POPUPWINDOW, $WS_GROUP, $WS_TABSTOP, $WS_BORDER, $WS_CLIPSIBLINGS))
#forceref $hGui
$_idEdit_Num = GUICtrlCreateEdit("", 0, 0, 25, 165, BitOR($ES_AUTOVSCROLL, $ES_READONLY), 0)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetData(-1, "1")
GUICtrlSetBkColor(-1, 0xC0DCC0)
GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKBOTTOM + $GUI_DOCKWIDTH)
$_idEdit_Main = GUICtrlCreateEdit("", 26, 0, 96, 175, -1, 0)
GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKRIGHT + $GUI_DOCKTOP + $GUI_DOCKBOTTOM)
GUICtrlCreateLabel("", 0, 164, 25, 11)
GUICtrlSetBkColor(-1, 0xC0DCC0)
GUICtrlSetResizing(-1, $GUI_DOCKLEFT + $GUI_DOCKTOP + $GUI_DOCKBOTTOM + $GUI_DOCKWIDTH)
GUISetState(@SW_SHOW)
AdlibRegister("_LineNum", 100)
Local $Msg
While 1
$Msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
EndFunc ;==>Example
Func _LineNum() ; line numbering
Local $iCount = _GUICtrlEdit_GetLineCount($_idEdit_Main)
;Check if the number of lines has changed in $_idEdit_Main
;since this function was last called
If $iCount <> $g_iMainLineCount Then
;save the new count to the global variable
$g_iMainLineCount = $iCount
Local $iNumCount = _GUICtrlEdit_GetLineCount($_idEdit_Num)
If $g_iMainLineCount > $iNumCount Then
For $i = $iNumCount + 1 To $g_iMainLineCount
_GUICtrlEdit_AppendText($_idEdit_Num, @CRLF & $i)
Next
ElseIf $g_iMainLineCount < $iNumCount Then
Local $text = GUICtrlRead($_idEdit_Num)
For $i = $iNumCount To $g_iMainLineCount + 1 Step -1
$text = StringReplace($text, @CRLF & $i, "")
Next
GUICtrlSetData($_idEdit_Num, $text)
EndIf
EndIf
Local $iFirstVisMain = _GUICtrlEdit_GetFirstVisibleLine($_idEdit_Main)
Local $iFirstVisNum = _GUICtrlEdit_GetFirstVisibleLine($_idEdit_Num)
If $iFirstVisMain <> $iFirstVisNum Then
_GUICtrlEdit_LineScroll($_idEdit_Num, 0, $iFirstVisMain - $iFirstVisNum)
EndIf
EndFunc ;==>_LineNum