Jump to content

Auto update GUI Control within the same GUI Form


mtmartis
 Share

Recommended Posts

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
Link to comment
Share on other sites

  • Moderators

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

 

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...