Jump to content
Sign in to follow this  
duckling78

Edit control has 30000 character limit

Recommended Posts

duckling78

It looks like the default Edit control maximum character limit is 30000 characters.

Is there a systematic way to delete the oldest line to give room for the newest line in that 30000 character buffer? I didn't find any functions specific for this and thought doing stuff like sending CTRL+HOME, SHIFT+PGDN, DEL, CTRL+END would be kind of cheezy.

I don't really want to continually increase the maximum text length. This will mostly be for a short status history thing for a GUI front end. It's ok if the oldest messages are lost because these same messages will be getting recorded to a file.

Here is a sample (the deleting stuff would replace the commented out text):

#include <GUIConstants.au3>
#include <GuiEdit.au3>

Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=C:\Scripts\BannerPerformanceTracker\Backups\MemoryLeakThingie.kxf
$Form1 = GUICreate("Form1", 1024, 447)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Button1 = GUICtrlCreateButton("Spam ON", 2, 2, 101, 25, 0)
GUICtrlSetOnEvent(-1, "Button1Click")
$Edit1 = GUICtrlCreateEdit("", 2, 28, 1019, 415, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_VSCROLL))
GUICtrlSetData(-1, "_GUICtrlEdit_GetLimitText: " & _GUICtrlEdit_GetLimitText($Edit1))
$Button2 = GUICtrlCreateButton("Spam OFF", 112, 2, 101, 25, 0)
GUICtrlSetOnEvent(-1, "Button2Click")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

GUICtrlSetData($Edit1, @CRLF & @ScriptName & " started.  Line: " & @ScriptLineNumber, 1)

Local $spam = 0

While 1
    Sleep(100)
   
    If $spam = 1 Then
        If(_GUICtrlEdit_GetTextLen($Edit1) > (_GUICtrlEdit_GetLimitText($Edit1) * .90)) Then
            ;### Need code here to get rid of a few lines from oldest strings in edit box... ###
        EndIf
        Blah("_GUICtrlEdit_GetTextLen: " & _GUICtrlEdit_GetTextLen($Edit1) & _
            " - SPAM SPAM SPAM SPAM SPAM SPAM SPAM SPAM SPAM SPAM SPAM SPAM SPAM SPAM SPAM SPAM SPAM SPAM SPAM SPAM SPAM SPAM SPAM SPAM SPAM")
    EndIf
WEnd

Func Blah($text)
    _GUICtrlEdit_AppendText($Edit1, @CRLF & $text)
EndFunc

Func Button1Click()
    $spam = 1
EndFunc
Func Button2Click()
    $spam = 0
EndFunc
Func Form1Close()
    Exit
EndFunc

Thanks! :)

Share this post


Link to post
Share on other sites
duckling78

This does seem to work, but I don't think it is the optimal solution:

ControlSend($appTitle, "", $Edit1, "^{HOME}+{PGDN}{DEL}^{END}")

Share this post


Link to post
Share on other sites
duckling78

This does seem to work, but I don't think it is the optimal solution:

ControlSend($appTitle, "", $Edit1, "^{HOME}+{PGDN}{DEL}^{END}")
Confirmed the above code is bad... A few minutes of running that while working on other stuff caused rogue "send" keystrokes in code I was working on causing a lot of it to be deleted :)

Share this post


Link to post
Share on other sites
duckling78

Confirmed the above code is bad... A few minutes of running that while working on other stuff caused rogue "send" keystrokes in code I was working on causing a lot of it to be deleted ;)

Lol... I think I just figured it out.

GUICtrlSetData($Edit1, StringRight(_GUICtrlEdit_GetText($Edit1), 25000))

Sorry for the quick post, replies and fix. Maybe this will help someone out at least? :)

  • Like 1

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×