kingjacob90

GUI input data into log form.

5 posts in this topic

#1 ·  Posted (edited)

Hi.

I am wanting to have a script that when you push a button it will put data from an input box into a list (like  data log) but the list must also have the previous data as well. I have code that dose this but I have the problem of it not been able to scroll as I am using an input box to store my data.

Any ideas?

Thanks. 

Global $top = 0

GUICreate("...",200,300)
$top=$top+10
GUICtrlCreateLabel("-- input hear --",2,$top,150,20)

$top=$top+20
$Input = GUICtrlCreateInput("",2,$top,100,20)
$Button = GUICtrlCreateButton("Submit",105,$top-1.5,90,23)

$top=$top+25
$View = GUICtrlCreateInput("-- data under hear --",2,$top,196,100,0x0004,0x0800)

GUISetState()
While 1
    $GUI_MSG = GUIGetMsg()
    Select
        Case $GUI_MSG = -3
            Exit

        Case $GUI_MSG = $Button
            GUICtrlSetData($View,GUICtrlRead($View)&@CRLF&"data: "&GUICtrlRead($Input))
            GUICtrlSetData($Input,"")


    EndSelect
WEnd

 

Edited by kingjacob90

Share this post


Link to post
Share on other sites



kingjacob90,

Inputs are forced to a single line - use an edit control instead:

; Use named constants - not "magic numbers"
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>
#include <ScrollBarsConstants.au3>

Global $top = 0

GUICreate("...", 200, 300)

$top = $top + 10
GUICtrlCreateLabel("-- input here --", 2, $top, 150, 20)

$top = $top + 20
$Input = GUICtrlCreateInput("", 2, $top, 100, 20)
$Button = GUICtrlCreateButton("Submit", 105, $top - 1.5, 90, 23)

$top = $top + 25
; Use a read-only edit control
$View = GUICtrlCreateEdit("-- data under hear --", 2, $top, 196, 100, BitOr($ES_READONLY, $WS_VSCROLL, $ES_AUTOVSCROLL), $WS_EX_STATICEDGE)

GUISetState()


While 1
    ; I prefer Switch to Select
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Button
            GUICtrlSetData($View, GUICtrlRead($View) & @CRLF & "data: " & GUICtrlRead($Input))
            ; Scroll to the bottom
            _GUICtrlEdit_Scroll($View, $SB_SCROLLCARET)
            GUICtrlSetData($Input, "")
            ; Refocus on the input
            GUICtrlSetState($Input, $GUI_FOCUS)

    EndSwitch
WEnd

You will note one or two other comments as well - please ask if you have any questions.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

kingjacob90,

Inputs are forced to a single line - use an edit control instead:

; Use named constants - not "magic numbers"
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>
#include <ScrollBarsConstants.au3>

Global $top = 0

GUICreate("...", 200, 300)

$top = $top + 10
GUICtrlCreateLabel("-- input here --", 2, $top, 150, 20)

$top = $top + 20
$Input = GUICtrlCreateInput("", 2, $top, 100, 20)
$Button = GUICtrlCreateButton("Submit", 105, $top - 1.5, 90, 23)

$top = $top + 25
; Use a read-only edit control
$View = GUICtrlCreateEdit("-- data under hear --", 2, $top, 196, 100, BitOr($ES_READONLY, $WS_VSCROLL, $ES_AUTOVSCROLL), $WS_EX_STATICEDGE)

GUISetState()


While 1
    ; I prefer Switch to Select
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Button
            GUICtrlSetData($View, GUICtrlRead($View) & @CRLF & "data: " & GUICtrlRead($Input))
            ; Scroll to the bottom
            _GUICtrlEdit_Scroll($View, $SB_SCROLLCARET)
            GUICtrlSetData($Input, "")
            ; Refocus on the input
            GUICtrlSetState($Input, $GUI_FOCUS)

    EndSwitch
WEnd

You will note one or two other comments as well - please ask if you have any questions.

M23

Thanks Melba23 Just what I wanted! :D

Share this post


Link to post
Share on other sites

kingjacob90,

Glad I could help. But when you reply, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - I know what I wrote and it just pads the thread unnecessarily.

M23

 


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

I see thanks I have not used the forums much. Very helpful! Thanks again. :lol:

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