aa2zz6

Puzzled with GUICtrlCreateEdit

5 posts in this topic

#1 ·  Posted (edited)

For the GUICtrlCreateEdit I thought there was a way to clear all text inside but I can't seem to find the resource on how to do this.

And when the program is running and new text is added is it possible to show the new stuff instead of the old? The GUICtrlCreateEdit  doesn't scroll down to the new. 

This is how I currently have it set to.

$log = GUICtrlCreateEdit("", 20, 40, 460, 400, BitOR($ES_WANTRETURN, $ES_READONLY, $ES_AUTOVSCROLL, $WS_VSCROLL))

 

Edited by aa2zz6

Share this post


Link to post
Share on other sites



#2 ·  Posted

aa2zz6,

Write noting to the edit control like this...

#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>
#include <date.au3>

#AutoIt3Wrapper_Add_Constants=n

Local $gui010 = GUICreate('Edit Example')
$log = GUICtrlCreateEdit("", 20, 40, 360, 300)
Local $btn010 = GUICtrlCreateButton('Clear', 20, 360, 360, 20)
GUISetState()

AdlibRegister('Write_Log', 100)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $btn010
            GUICtrlSetData($log, '') ;  <-----  clear the log
    EndSwitch
WEnd

; fill the log up to show scrolling
Func Write_Log()
    GUICtrlSetData($log, _NowCalc() & @CRLF, 1)
EndFunc   ;==>Write_Log

Most of the styles you specify are already defaults...

kylomas

1 person likes this

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks kylomas

Would there be anyway to allow the new text to appear as it's being recorded? Currently it's stuck at the top and doesn't scroll down with the new text. I check for a style to allow this and there was nothing from what I could see.

Edited by aa2zz6

Share this post


Link to post
Share on other sites

#4 ·  Posted

#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <ScrollBarsConstants.au3>

#include <date.au3>

#AutoIt3Wrapper_Add_Constants=n

Local $gui010 = GUICreate('Edit Example')
$log = GUICtrlCreateEdit("", 20, 40, 360, 300)
Local $btn010 = GUICtrlCreateButton('Clear', 20, 360, 360, 20)
GUISetState()

AdlibRegister('Write_Log', 100)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $btn010
            GUICtrlSetData($log, '') ;  <-----  clear the log
    EndSwitch
WEnd

; fill the log up to show scrolling
Func Write_Log()
    GUICtrlSetData($log, _NowCalc() & @CRLF, 1)
    $iEnd = StringLen(GUICtrlRead($gui010))
    _GUICtrlEdit_SetSel($gui010, $iEnd, $iEnd)
    _GUICtrlEdit_Scroll($gui010, $SB_SCROLLCARET)
EndFunc   ;==>Write_Log

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

aa2zz6, subz,

F.Y.I, SetSel is Not required.  The third parm of GuiCtrlSetData ensures that the caret (insertion point) is always at the end...

#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiEdit.au3>
#include <ScrollBarsConstants.au3>

#include <date.au3>

#AutoIt3Wrapper_Add_Constants=n

Local $gui010 = GUICreate('Edit Example')
$log1 = GUICtrlCreateEdit("", 20, 40, 170, 300)
$log2 = GUICtrlCreateEdit("", 210, 40, 170, 300)
Local $btn010 = GUICtrlCreateButton('Clear', 20, 360, 360, 20)
GUISetState()

AdlibRegister('Write_Log', 100)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $btn010
            GUICtrlSetData($log1, '') ;  <-----  clear the logs
            GUICtrlSetData($log2, '') ;  <-----  clear the logs
    EndSwitch
WEnd

; fill the log up to show scrolling
Func Write_Log()
    GUICtrlSetData($log1, _NowCalc() & @CRLF, 1)
    GUICtrlSetData($log2, _NowCalc() & @CRLF, 1)
    ;$iEnd = StringLen(GUICtrlRead($gui010))
    ;_GUICtrlEdit_SetSel($gui010, $iEnd, $iEnd)
    ;_GUICtrlEdit_Scroll($log1, $SB_SCROLLCARET)
EndFunc   ;==>Write_Log

kylomas

edit: None of the scrolling is required.

Edited by kylomas
Clarification
2 people like this

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

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