TheDcoder Posted August 10, 2020 Share Posted August 10, 2020 Hello everyone, Not too long ago I stumbled across the buffer limit in an edit control, at first I thought it must be a bug in my code, but after some investigation I quickly found out that the edit control by default has a limit of characters it can display... for me it can only show 30K characters, here is a reproducer script I wrote (by forking the example code): #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Example() Func Example() GUICreate("My GUI edit", 500, 500) Local $idMyedit = GUICtrlCreateEdit("", 0, 0, 500, 500, $ES_AUTOVSCROLL + $WS_VSCROLL) GUISetState(@SW_SHOW) Local $sPrevString While True GUICtrlSetData($idMyedit, "0123456789", 1) Local $sCurrString = GUICtrlRead($idMyedit) If $sPrevString = $sCurrString Then ExitLoop $sPrevString = $sCurrString WEnd ConsoleWrite("Edit buffer limit reached at " & StringLen($sPrevString) & " characters." & @CRLF) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete() EndFunc Is there a way to increase or entirely remove this limit? How can I find out the buffer size of a certain edit control? Failing that, is there an efficient way to check if I have hit the buffer limit? I am sure many of you have come across this issue, and I am hoping for a good work around Thanks for the help in advance! EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
Danp2 Posted August 10, 2020 Share Posted August 10, 2020 GUICtrlSetLimit appears to be the solution to your issue. TheDcoder 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Musashi Posted August 10, 2020 Share Posted August 10, 2020 1 hour ago, TheDcoder said: ... for me it can only show 30K characters, ... This also may be an option (with example) : #include <GUIConstantsEx.au3> #include <GuiEdit.au3> _Example() Func _Example() Local $idEdit, $sRead , $sFilename ; Example : Read GDIPlus.au3 and show the code in an Edit control : $sFilename = StringRegExpReplace(@AutoItExe, "(?i)AutoIt3.exe$", "") & "Include\GDIPlus.au3" $sRead = FileRead($sFilename) GUICreate("Test : Huge Edit Control", 1200, 600) $idEdit = GUICtrlCreateEdit("", 2, 2, 1194, 568) ; Gets the current text limit for an edit control ConsoleWrite('1. _GUICtrlEdit_GetLimitText($idEdit) = ' & _GUICtrlEdit_GetLimitText($idEdit) & @CRLF) ; Sets the text limit _GUICtrlEdit_SetLimitText($idEdit, 1500000) ConsoleWrite('2. _GUICtrlEdit_GetLimitText($idEdit) = ' & _GUICtrlEdit_GetLimitText($idEdit) & @CRLF) GUISetState(@SW_SHOW) _GUICtrlEdit_AppendText($idEdit, $sRead) ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>_Example  TheDcoder 1 "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
TheSaint Posted August 10, 2020 Share Posted August 10, 2020 I've come across this issue too, and from my recollection, the limit is not limitless, and that the 30K characters may be the upper limit (or close to it), and you can mostly only set a lesser one. But perhaps I am wrong ... hopefully so? Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
Danp2 Posted August 10, 2020 Share Posted August 10, 2020 Not sure about limitless, but I ran a test with 50k as the limit and it worked as expected. TheSaint 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
TheSaint Posted August 10, 2020 Share Posted August 10, 2020 (edited) Sounds promising ... so maybe I misread/misremembered something. I have used pretend DOS consoles (an Edit) in a few of my programs with STDOUT, and sometimes that 32k limit causes grief. Edited August 10, 2020 by TheSaint Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
Musashi Posted August 10, 2020 Share Posted August 10, 2020 46 minutes ago, Danp2 said: Not sure about limitless, but I ran a test with 50k as the limit and it worked as expected. Â 15 minutes ago, TheSaint said: Sounds promising ... so maybe I misread/misremembered something. I did a hardcore test out of curiosity. I generated a text file with 20.000 lines (1.360.000 bytes) and read it into my example (see above) ==> No problems ! Of course there will be a limit, but it seems to be very high . Danp2, TheDcoder and TheSaint 2 1 "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
TheDcoder Posted August 11, 2020 Author Share Posted August 11, 2020 Thank you all for the input (sic), I always look the obvious functions like SetLimitText . I did a test and it looks promising: expandcollapse popup#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GuiEdit.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> Example() Func Example() GUICreate("My GUI edit", 500, 500) Local $idMyedit = GUICtrlCreateEdit("", 0, 0, 500, 500, $ES_AUTOVSCROLL + $WS_VSCROLL) GUISetState(@SW_SHOW) Local $sDumpString = "0123456789" Local $sPrevString While True While True GUICtrlSetData($idMyedit, $sDumpString, 1) Local $sCurrString = GUICtrlRead($idMyedit) If $sPrevString = $sCurrString Then ExitLoop $sPrevString = $sCurrString WEnd Local $iLimit = StringLen($sPrevString) ConsoleWrite("Edit buffer limit reached at " & $iLimit & " characters." & @CRLF) If MsgBox($MB_YESNO, "Buffer Limit", "Edit buffer limit reached at " & $iLimit & " characters. Do you want to continue?") = $IDNO Then ExitLoop $sDumpString = GUICtrlRead($idMyedit) _GUICtrlEdit_SetLimitText($idMyedit, $iLimit * 2) WEnd ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete() EndFunc I was able to increase the limit up-to 960K characters, after that the GUI stopped responding when the script was attempting to insert another 960K characters. So hopefully we can keep track of the count and increase the limit as we go dynamically. Will implement this in my real script and report back in a few weeks TheSaint 1 EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion 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