Sign in to follow this  
Followers 0
tammelinn

_GUICtrlEdit_AppendText problems

9 posts in this topic

Several posters have recommended using _GUICtrlEdit_AppendText in an edit box to get text to scroll smoothly, but I can't get it working at all.

When the edit box is full, instead of scrolling, it freezes and beeps in complaint.

Since it's a beta function, naturally I have no idea where to find the documentation for it.

Here's the old code, which works fine but goes in an unnatural direction:

$mainoutputtext = GUICtrlCreateEdit ("", 0, 0, ($mainwindowwidth-200), ($mainwindowheight-120), $ES_READONLY)
...
GUICtrlSetData ($mainoutputtext, $text & @CRLF & GUICtrlRead ($mainoutputtext), "")

And here's the new code, which won't scroll at all:

$mainoutputtext = GUICtrlCreateEdit ("", 0, 0, ($mainwindowwidth-200), ($mainwindowheight-120), $ES_READONLY)
...
_GUICtrlEdit_AppendText($mainoutputtext, $text & @CRLF)

What do I need to do to make the second piece of code behave like the first one?

Share this post


Link to post
Share on other sites

Well, to solve the first issue, you could always increase the size allowed for the edit box from (I think) 64kb to something more... with GUICtrlSetLimit(), that way you don't have to play with a function you are unfamiliar with until you can see it properly executed.

Gary added so many of them, that I kind of dread making a GUI now a days :P


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Thanks for your suggestion. In case it wasn't clear, the output box complains with a <beep> the moment it fills up - not when the memory limit is reached. (Just tested it.)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

What do you mean "fills up" ??

*Edit: Also had to address this:

Since it's a beta function, naturally I have no idea where to find the documentation for it.

It's in the help files. Edited by Saunders

Share this post


Link to post
Share on other sites

Do you have a reproduction script? I can't get mine to "beep" at me, but I did find that the limit was stopping at 29kb for me, until I reset the limit allowed.

What styles are you using (actually just post the replication script so I can see for myself).


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Do you have a reproduction script? I can't get mine to "beep" at me, but I did find that the limit was stopping at 29kb for me, until I reset the limit allowed.

Here's a simplified script which shows my problem.

First, my old script (which doesn't use GUICtrlEdit_AppendText). New text is created at the top of the screen, and everything scrolls down. When the screen is full, the oldest text disappears.

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

; Declare variables
; -----------------

; The main output window's format
Const $mainwindowwidth = 700
Const $mainwindowheight = 450
; The handle of the GUI window
Global $mainoutputhandle
; The name of the edit control where messages will appear
Global $mainoutputtext

; Minimum period between each loop of the script in milliseconds
Const $loopdelay = 1000

; Keep track of the time
Global $timestamp

; Local variables
Local $count

; Create the window
; -----------------

; Open the main output window in its initial position of top-left corner
    
; Change to OnEvent mode
Opt("GUIOnEventMode", 1)  

; Open the window 
$mainoutputhandle = GUICreate("Test script", ($mainwindowwidth), ($mainwindowheight-50), 0, 0)
GUISetState(@SW_SHOW)

; Create black box of white text in the window
$mainoutputtext = GUICtrlCreateEdit ("", 0, 0, ($mainwindowwidth-200), ($mainwindowheight-120), $ES_READONLY)
GUICtrlSetColor($mainoutputtext, 0xFFFFFF)
GUICtrlSetBkColor($mainoutputtext, 0x000000)

; Main loop
; ---------

; Set the timer
$timestamp = TimerInit()

; Every second, write a line of text to edit control

Do
    Sleep($loopdelay)
    
; Write a line of text in the edit control
        
; Uncomment one of the next two lines of code   
; _GUICtrlEdit_AppendText($mainoutputtext, "Test line, time: " & TimerDiff($timestamp) & @CRLF)
     GUICtrlSetData ($mainoutputtext, "Test line " & TimerDiff($timestamp) & @CRLF & GUICtrlRead ($mainoutputtext), "")
        
Until TimerDiff($timestamp) >= 30000

; Terminate the script after 30 seconds
Exit 0

So far, so good. Now, to see what happens when you use _GUICtrlEdit_AppendText, just replace these lines...

; Uncomment one of the next two lines of code   
; _GUICtrlEdit_AppendText($mainoutputtext, "Test line, time: " & TimerDiff($timestamp) & @CRLF)
     GUICtrlSetData ($mainoutputtext, "Test line " & TimerDiff($timestamp) & @CRLF & GUICtrlRead

...with these...

; Uncomment one of the next two lines of code   
    _GUICtrlEdit_AppendText($mainoutputtext, "Test line, time: " & TimerDiff($timestamp) & @CRLF)
; GUICtrlSetData ($mainoutputtext, "Test line " & TimerDiff($timestamp) & @CRLF & GUICtrlRead

I'd like new lines of text to appear at the bottom, with the oldest lines at the top disappearing when the edit control is full. A scroll bar would be nice, but I can live without it.

I'm using AutoIt 3.2.9.8 .

Edited by tammelinn

Share this post


Link to post
Share on other sites

The solution is to change...

$mainoutputtext = GUICtrlCreateEdit ("", 0, 0, ($mainwindowwidth-200), ($mainwindowheight-120), $ES_READONLY)oÝ÷ ÚÚºÚ"µÍÌÍÛXZ[Ý]]^HÕRPÝÜX]QY]
    ][ÝÉ][ÝË
    ÌÍÛXZ[Ú[ÝÝÚYL
K
    ÌÍÛXZ[Ú[ÝÚZYÚLL

...though why scrolling text is only allowed on non-readonly windows is a mystery to me.

Share this post


Link to post
Share on other sites

I guess your problem comes from your Edit not being "Multiline" ($ES_MULTILINE)

To have a vertical scroll bar: $WS_VSCROLL

In one of my old scripts I've created an editbox using the following code:

$Edit2 = GUICtrlCreateEdit("", 11, 72, 645, 313, BitOR($ES_MULTILINE, $ES_READONLY,$WS_VSCROLL, $WS_BORDER))

Just change the dimensions and put it into your script - see how it behaves.

Good luck,


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

Bravo! The correct line, then, is...

$mainoutputtext = GUICtrlCreateEdit ("", 0, 0, ($mainwindowwidth-200), ($mainwindowheight-120), BitOR($ES_MULTILINE, $ES_READONLY,$WS_VSCROLL, $WS_BORDER))

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  
Followers 0