billthecreator Posted May 23, 2007 Share Posted May 23, 2007 (edited) I was wondering how to put line numbers in an edit like the way autoit looks. Can anybody help me? Edited May 23, 2007 by billthecreator [font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap Link to comment Share on other sites More sharing options...
dryan Posted May 23, 2007 Share Posted May 23, 2007 Here is a start. I'm sure there are probably better ways to do it, but since you haven't received a response, I thought I'd give you something to work off of. expandcollapse popup#include <GUIConstants.au3> #include <GuiEdit.au3> #include <Misc.au3> $form = GUICreate("Line Numbers on Edit", 633, 447, 193, 115) $edit = GUICtrlCreateEdit("", 8, 8, 617, 433) GUICtrlSetData(-1, "|1| Some text on line 1"&@CRLF&"|2| The second line of text"&@CRLF&"|3| Some more"&@CRLF&"|4| and more") GUISetState(@SW_SHOW) $button = GUICtrlCreateButton ("add nums",0,0,50,50) GUICtrlSetState($button,$GUI_HIDE) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch If _IsPressed ("0D") Then addNums() While _IsPressed ("0D") Sleep(20) ; Avoid excessive number of calls to addNums WEnd addNums() EndIf WEnd Func addNums() $text = GUICtrlRead($edit) $arr = StringSplit($text,@CRLF,1) $finaltext = "" For $i = 1 To $arr[0] $linetext = $arr[$i] If StringRegExp($linetext,"\A\|(([0-9]{1,5})\|)",1)=1 Then $finaltext = $finaltext & @CRLF & "|"&$i&"| "&$linetext Else $finaltext = $finaltext & @CRLF & $linetext EndIf Next GUICtrlSetData($edit,StringRight ($finaltext,StringLen($finaltext)-2)) EndFunc Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now