mtmartis

Auto update GUI Control within the same GUI Form

4 posts in this topic

#1 ·  Posted (edited)

Can someone point me in the right direction on how to update a gui control that uses a previous control as a variable on the same form once it's modified?

In the code , $var1 references a previous control, $input1.

How can I get the $lbl3 control to update as soon as data has been entered in the $input1 control. I am thinking of somehow checking if the $input1 control is not active (either by clicking another control or tabbing off of it) then update the $lvb3 control.

#include <GUIConstantsEx.au3>
$Form = GUICreate("Form1", 275, 208, 192, 124)
$lbl1 = GUICtrlCreateLabel("Enter Group Name", 40, 16, 92, 17)
$input1 = GUICtrlCreateInput("Data Field", 40, 40, 121, 21)
$cbox1 = GUICtrlCreateCheckbox("Is Allowed", 48, 80, 97, 17)
$lbl2 = GUICtrlCreateLabel("File Name will be:", 40, 120, 100, 17)
$var1 = GUICtrlRead($input1, $GUI_READ_EXTENDED)
$lbl3 = GUICtrlCreateLabel($var1 & "_datafile.txt", 45, 140, 200, 33)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg

        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

 

Edited by mtmartis

Share this post


Link to post
Share on other sites



mtmartis,

Look for the input content being changed and update the label accordingly:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <WinAPI.au3>

$Form = GUICreate("Form1", 275, 208, 192, 124)

$lbl1 = GUICtrlCreateLabel("Enter Group Name", 40, 16, 92, 17)
$input1 = GUICtrlCreateInput("Data Field", 40, 40, 121, 21)
$cbox1 = GUICtrlCreateCheckbox("Is Allowed", 48, 80, 97, 17)
$lbl2 = GUICtrlCreateLabel("File Name will be:", 40, 120, 100, 17)
$var1 = GUICtrlRead($input1, $GUI_READ_EXTENDED)
$lbl3 = GUICtrlCreateLabel($var1 & "_datafile.txt", 45, 140, 200, 33)

GUISetState(@SW_SHOW)

GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg

        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Func _WM_COMMAND($hWHnd, $iMsg, $wParam, $lParam)

    ; If it was an update message from our input
    If _WinAPI_HiWord($wParam) = $EN_CHANGE And _WinAPI_LoWord($wParam) = $input1 Then

        ; Set the label to the new data
        GUICtrlSetData($lbl3, GUICtrlRead($input1))

    EndIf

EndFunc   ;==>_WM_COMMAND

If you are not used to using GUIRegisterMsg, the GUIRegisterMsg tutorial in the Wiki will explain all about it.

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

Hi Melba,

I have never used GuiRegisterMsg before, I am digging into the help regarding it to learn what it does and how to use it. Thank you very much for your assistance!

-M

Share this post


Link to post
Share on other sites

mtmartis,

Do not hesitate to ask if you have any questions. I hope the tutorial to which I linked is clear, but it is a tricky subject...

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

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