therks 33 Posted April 21, 2010 (edited) Okay, so I've got this editor application and I wanted a line tracking column like Scite has. I've clipped this repro from the full application: expandcollapse popup#include <GUIConstants.au3> #include <WindowsConstants.au3> #include <GUIEdit.au3> Global Const $EDIT_MAX_LIMIT = 2^31-1 ; 0x7fffffff, 2147483647 Global $sLineCount = '' For $i = 1 to 2000 $sLineCount &= $i & @CRLF Next $hGUI = GUICreate('', 400, 300, Default, Default, $WS_OVERLAPPEDWINDOW) $ed_Lines = GUICtrlCreateEdit('1', 0, 0, 50, 300, BitOR($ES_READONLY, $ES_RIGHT)) GUICtrlSetResizing(-1, BitXOR($GUI_DOCKBORDERS, $GUI_DOCKRIGHT, $GUI_DOCKWIDTH)) _GUICtrlEdit_SetLimitText($ed_Lines, $EDIT_MAX_LIMIT) $ed_Content = GUICtrlCreateEdit('Hello!', 50, 0, 350, 300) GUICtrlSetResizing(-1, $GUI_DOCKBORDERS) _GUICtrlEdit_SetLimitText($ed_Content, $EDIT_MAX_LIMIT) GUISetState() GUIRegisterMsg($WM_CTLCOLOREDIT, 'WM_CTLCOLOREDIT') While 1 $gm = GUIGetMsg() Switch $gm Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func WM_CTLCOLOREDIT($hWnd, $iMsg, $iWParam, $iLParam) If $iLParam = GUICtrlGetHandle($ed_Content) Then _GUICtrlEdit_BeginUpdate($ed_Lines) If Not IsDeclared('STATIC___iLineCountMem') Then Global $STATIC___iLineCountMem = -1 Local $iLineCount = _GUICtrlEdit_GetLineCount($ed_Content) If $iLineCount <> $STATIC___iLineCountMem then Local $iCutOff = StringInStr($sLineCount, @CRLF, 0, $iLineCount) If $iCutOff = 0 Then Global $sLineCount = '' For $i = 1 to $iLineCount + 100 $sLineCount &= $i & @CRLF Next $iCutOff = StringInStr($sLineCount, @CRLF, 0, $iLineCount) EndIf GUICtrlSetData($ed_Lines, StringLeft($sLineCount, $iCutOff+1)) $STATIC___iLineCountMem = $iLineCount EndIf If Not IsDeclared('STATIC___iLineVisMem') Then Global $STATIC___iLineVisMem = -1 Local $iLineVis = _GUICtrlEdit_GetFirstVisibleLine($ed_Content) If $iLineVis <> $STATIC___iLineVisMem Then _GUICtrlEdit_LineScroll($ed_Lines, 0, -$iLineCount) _GUICtrlEdit_LineScroll($ed_Lines, 0, $iLineVis) EndIf _GUICtrlEdit_EndUpdate($ed_Lines) EndIf Return $GUI_RUNDEFMSG EndFunc Now it works, and it works pretty good, but in instances where I paste a large amount of text in, it's rather slow to respond. A 1000 line script I have for instance takes almost 3 seconds before it appears, also resizing and scrolling when there's lots of text is choppy as well. I'm hoping someone with better GUI knowledge than I (which shouldn't be hard) will weigh in here with some advice on ways I could make this run faster. Maybe a better strategy for filling the lines column? Maybe even a better message to hook into. I'm not sure WM_CTLCOLOREDIT is the best, but it triggers whenever the edit is scrolled, resized, or changed so it fit my purpose. Thanks for reading. *Edit: Edited the title, it was too long. Edited April 21, 2010 by therks My AutoIt Stuff | My Github Share this post Link to post Share on other sites
PsaltyDS 39 Posted April 23, 2010 I can't reproduce the problem. I pasted multiple copies of your code into the running editor until there was over 1000 lines, then cut and pasted it in/out a few times and the update was near instantaneous every time. This is a pretty beefy box (AutoIt 3.3.6.1, Vista Busi 32bit, on Q8300 quad 2.5GHz, 4GB) and I'm sure that helps. What are you running it on? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Share this post Link to post Share on other sites
therks 33 Posted April 24, 2010 WinXP Pro, 2.31GHz, 2GB RAM. I just updated to AutoIt 3.3.6.1 (was running the latest Beta, I always forget to check the release version to see what's newer haha) and still runs the same way. Thanks for checking it out though Psalty, glad it works well for you. Any ideas that can increase performance anyway? Or does everything already seem up to snuff? My AutoIt Stuff | My Github Share this post Link to post Share on other sites