Sign in to follow this  
Followers 0
CheapoDepot

Update New Text Box

6 posts in this topic

I am trying to get the GUI to work so that when new data is entered in any field or combo and the "Update" button is pressed, the text box is updated. Or even better, take out the "Update" button and have the GUI automatically update the text box as the fields and combos are filled.

Thanks in advance.

#include <GUIConstants.au3>

DIM $s_text,$DD_display0,$sl1
DIM $p_text,$DD_display1
DIM $a,$b,$c,$d,$e,$f,$g
DIM $aa,$bb,$cc,$dd,$ee,$ff
DIM $button1

GUICreate("Drainage Description", 600, 500, -1, -1) ; will create a dialog box that when displayed is centered

GUISetBkColor(0x00E0FFFF)
GUISetFont(9, 300)

$tab=GUICtrlCreateTab (10,10, 580,480)
;===============================================================================
$tab0=GUICtrlCreateTabitem ("Stucture")
GUICtrlCreateLabel ("Structure Number:", 20,120,100,20)
$aa=GUICtrlCreateInput ("1-1", 130,118,45,20)
GUICtrlCreateLabel ("Structure:", 20,150,55,20)
GUICtrlCreateCombo ("", 130,148,60,120)
$bb=GUICtrlSetData(-1,"_|DI-3A|DI-3B|DI-3BB|DI-4C|DI-4CC", "_"); default "_"
GUICtrlCreateLabel ("Length:", 20,180,55,20)
$cc=GUICtrlCreateInput ("", 130,178,35,20)
GUICtrlCreateLabel ("Height:", 20,210,55,20)
$dd=GUICtrlCreateInput ("", 130,208,35,20)
GUICtrlCreateLabel ("Top of Structure:", 20,240,95,20)
$ee=GUICtrlCreateInput ("", 130,238,35,20)
GUICtrlCreateLabel ("Invert of Structure:", 20,270,120,20)
$ff=GUICtrlCreateInput ("", 130,268,35,20)
;GUICtrlCreateCheckbox("IS-1",300,115)
;GUICtrlCreateCheckbox("Height of structure is less than minimum std. height req'd",200,230)
;$sl1=GUICtrlCreateCheckbox("SL-1",300,210)
$s_text = GUICtrlRead($aa) & "  1-St'd. " & GUICtrlRead($bb) & " Req'd" & @CRLF & _
                        "   L=" & GUICtrlRead($cc) & "' H=" & GUICtrlRead($dd) & "' Inv. " & GUICtrlRead($ee) & "' TOP=" & GUICtrlRead($ff)
$DD_display0=GUICtrlCreateEdit($s_text, 20, 370, 250, 70, $ES_AUTOVSCROLL + $WS_VSCROLL)
GUICtrlCreateButton ("Update", 20,298,75,25)

GUICtrlSetState($sl1, $GUI_DISABLE)             ;Greys out Control
GUICtrlSetState($dd, $GUI_DISABLE)              ;Greys out Control
GUICtrlSetState($DD_display0, $GUI_DISABLE)             ;Greys out Control
;===============================================================================
$tab1=GUICtrlCreateTabitem ("Pipe")
GUICtrlSetState(-1,$GUI_SHOW)  ; will display first
    GUICtrlCreateLabel ("Pipe Number:", 20,90,100,20)
    $a=GUICtrlCreateInput ("1-2", 130,88,45,20)
    GUICtrlCreateLabel ("Length:", 20,120,55,20)
    $b=GUICtrlCreateInput ("", 130,118,45,20)
    GUICtrlCreateLabel ("Pipe Diameter:", 20,150,100,20)
    GUICtrlCreateCombo ("", 130,148,60,120)
    $c=GUICtrlSetData(-1,"_|15|18|21|24", "_"); default "_"
    GUICtrlCreateLabel ("Pipe Material:", 20,180,100,20)
    GUICtrlCreateCombo ("", 130,178,120,120)
    $d=GUICtrlSetData(-1,"Concrete|Corrugate Metal|PVC|Pipe", "Concrete"); default "Concrete"
    GUICtrlCreateLabel ("Cover:", 20,210,120,20)
    $e=GUICtrlCreateInput ("", 130,208,35,20)   
    GUICtrlCreateLabel ("Invert IN:", 20,240,55,20)
    $f=GUICtrlCreateInput ("", 130,238,45,20)
    GUICtrlCreateLabel ("Invert OUT:", 20,270,95,20)
    $g=GUICtrlCreateInput ("", 130,268,45,20)
;GUICtrlCreateCheckbox("Place Text Here.",300,115)
    $p_text = GUICtrlRead($a) & "   " & GUICtrlRead($b) & " - " & GUICtrlRead($c)  & GUICtrlRead($d) & " Pipe Req'd (" & GUICtrlRead($e) & "' Cover)" & @CRLF & _
                            "   Inv.(In) " & GUICtrlRead($f) & "' Inv.(Out) " & GUICtrlRead($g) & "'"
    $DD_display1=GUICtrlCreateEdit($p_text, 20, 370, 250, 70, $ES_AUTOVSCROLL + $WS_VSCROLL)
    $button1=GUICtrlCreateButton ("Update", 20,298,75,25)
    GUICtrlSetOnEvent(-1, "UpdatePressed")
    
    GUICtrlSetState($DD_display1, $GUI_DISABLE)             ;Greys out Control
;===============================================================================
$tab2=GUICtrlCreateTabitem ("SWM")
GUICtrlCreateLabel ("label2", 30,80,50,20)
$tab2OK=GUICtrlCreateButton ("OK2", 160,50,50)
;===============================================================================
GUICtrlCreateTabitem ("")  ; end tabitem definition


GUISetState ()

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Func UpdatePressed(ByRef $a, ByRef $p_text, ByRef $DD_display1)
EndFunc

Share this post


Link to post
Share on other sites



This should do what you want:

#include <GUIConstants.au3>

Global Const $WM_COMMAND = 0x0111
Global Const $EN_CHANGE = 0x300
Global Const $DebugIt = 1

Global Const $CBN_EDITCHANGE = 5;
Global Const $CBN_SELCHANGE = 1;
Global Const $CBN_EDITUPDATE = 6;


Dim $s_text, $DD_display0, $sl1
Dim $p_text, $DD_display1
Dim $a, $b, $c, $d, $e, $f, $g
Dim $aa, $bb, $cc, $dd, $ee, $ff
Dim $button1

GUICreate("Drainage Description", 600, 500, -1, -1) ; will create a dialog box that when displayed is centered

GUISetBkColor(0x00E0FFFF)
GUISetFont(9, 300)

$tab = GUICtrlCreateTab(10, 10, 580, 480)
;===============================================================================
$tab0 = GUICtrlCreateTabItem("Stucture")
GUICtrlCreateLabel("Structure Number:", 20, 120, 100, 20)
$aa = GUICtrlCreateInput("1-1", 130, 118, 45, 20)
GUICtrlCreateLabel("Structure:", 20, 150, 55, 20)
$bb = GUICtrlCreateCombo("", 130, 148, 60, 120)
GUICtrlSetData(-1, "_|DI-3A|DI-3B|DI-3BB|DI-4C|DI-4CC", "_"); default "_"
GUICtrlCreateLabel("Length:", 20, 180, 55, 20)
$cc = GUICtrlCreateInput("", 130, 178, 35, 20)
GUICtrlCreateLabel("Height:", 20, 210, 55, 20)
$dd = GUICtrlCreateInput("", 130, 208, 35, 20)
GUICtrlCreateLabel("Top of Structure:", 20, 240, 95, 20)
$ee = GUICtrlCreateInput("", 130, 238, 35, 20)
GUICtrlCreateLabel("Invert of Structure:", 20, 270, 100, 20)
$ff = GUICtrlCreateInput("", 130, 268, 35, 20)
;GUICtrlCreateCheckbox("IS-1",300,115)
;GUICtrlCreateCheckbox("Height of structure is less than minimum std. height req'd",200,230)
;$sl1=GUICtrlCreateCheckbox("SL-1",300,210)
$s_text = GUICtrlRead($aa) & "    1-St'd. " & GUICtrlRead($bb) & " Req'd" & @CRLF & _
        "    L=" & GUICtrlRead($cc) & "' H=" & GUICtrlRead($dd) & "' Inv. " & GUICtrlRead($ff) & "' TOP=" & GUICtrlRead($ee)
$DD_display0 = GUICtrlCreateEdit($s_text, 20, 370, 250, 70, $ES_AUTOVSCROLL + $WS_VSCROLL)
;~ GUICtrlCreateButton("Update", 20, 298, 75, 25)

GUICtrlSetState($sl1, $GUI_DISABLE)                ;Greys out Control
GUICtrlSetState($dd, $GUI_DISABLE)                ;Greys out Control
GUICtrlSetState($DD_display0, $GUI_DISABLE)                ;Greys out Control
;===============================================================================
$tab1 = GUICtrlCreateTabItem("Pipe")
GUICtrlSetState(-1, $GUI_SHOW)  ; will display first
GUICtrlCreateLabel("Pipe Number:", 20, 90, 100, 20)
$a = GUICtrlCreateInput("1-2", 130, 88, 45, 20)
GUICtrlCreateLabel("Length:", 20, 120, 55, 20)
$b = GUICtrlCreateInput("", 130, 118, 45, 20)
GUICtrlCreateLabel("Pipe Diameter:", 20, 150, 100, 20)
$c = GUICtrlCreateCombo("", 130, 148, 60, 120)
GUICtrlSetData(-1, "_|15|18|21|24", "_"); default "_"
GUICtrlCreateLabel("Pipe Material:", 20, 180, 100, 20)
$d = GUICtrlCreateCombo("", 130, 178, 120, 120)
GUICtrlSetData(-1, "Concrete|Corrugate Metal|PVC|Pipe", "Concrete"); default "Concrete"
GUICtrlCreateLabel("Cover:", 20, 210, 120, 20)
$e = GUICtrlCreateInput("", 130, 208, 35, 20)
GUICtrlCreateLabel("Invert IN:", 20, 240, 55, 20)
$f = GUICtrlCreateInput("", 130, 238, 45, 20)
GUICtrlCreateLabel("Invert OUT:", 20, 270, 95, 20)
$g = GUICtrlCreateInput("", 130, 268, 45, 20)
;GUICtrlCreateCheckbox("Place Text Here.",300,115)
$p_text = GUICtrlRead($a) & "    " & GUICtrlRead($B) & " - " & GUICtrlRead($c) & GUICtrlRead($d) & " Pipe Req'd (" & GUICtrlRead($e) & "' Cover)" & @CRLF & _
        "    Inv.(In) " & GUICtrlRead($f) & "' Inv.(Out) " & GUICtrlRead($g) & "'"
$DD_display1 = GUICtrlCreateEdit($p_text, 20, 370, 250, 70, $ES_AUTOVSCROLL + $WS_VSCROLL)
;~     $button1=GUICtrlCreateButton ("Update", 20,298,75,25)
;~     GUICtrlSetOnEvent(-1, "UpdatePressed")

GUICtrlSetState($DD_display1, $GUI_DISABLE)                ;Greys out Control
;===============================================================================
$tab2 = GUICtrlCreateTabItem("SWM")
GUICtrlCreateLabel("label2", 30, 80, 50, 20)
$tab2OK = GUICtrlCreateButton("OK2", 160, 50, 50)
;===============================================================================
GUICtrlCreateTabItem("")  ; end tabitem definition

GUICtrlSetState($tab0, $GUI_SHOW)


GUISetState()
GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

Func _Data_Changed()
    GUICtrlSetData($DD_display0, GUICtrlRead($aa) & "    1-St'd. " & GUICtrlRead($bb) & " Req'd" & @CRLF & _
            "    L=" & GUICtrlRead($cc) & "' H=" & GUICtrlRead($dd) & "' Inv. " & GUICtrlRead($ee) & "' TOP=" & GUICtrlRead($ff))
EndFunc   ;==>_Data_Changed

Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
    Local $nNotifyCode = _HiWord($wParam)
    Local $nID = _LoWord($wParam)
    Local $hCtrl = $lParam

    Switch $nID
        Case $aa, $cc, $dd, $ee, $ff
            Switch $nNotifyCode
                Case $EN_CHANGE
                    _Data_Changed()
            EndSwitch
        Case $bb
            Switch $nNotifyCode
                Case $CBN_EDITUPDATE, $CBN_EDITCHANGE ; when user types in new data
                    _Data_Changed()
                Case $CBN_SELCHANGE ; item from drop down selected
                    _Data_Changed()
            EndSwitch
    EndSwitch
    ; Proceed the default Autoit3 internal message commands.
    ; You also can complete let the line out.
    ; !!! But only 'Return' (without any value) will not proceed
    ; the default Autoit3-message in the future !!!
    Return $GUI_RUNDEFMSG
EndFunc   ;==>MY_WM_COMMAND

Func _DebugPrint($s_text)
    $s_text = StringReplace($s_text, @LF, @LF & "-->")
    ConsoleWrite("!===========================================================" & @LF & _
            "+===========================================================" & @LF & _
            "-->" & $s_text & @LF & _
            "+===========================================================" & @LF)
EndFunc   ;==>_DebugPrint


Func _HiWord($x)
    Return BitShift($x, 16)
EndFunc   ;==>_HiWord

Func _LoWord($x)
    Return BitAND($x, 0xFFFF)
EndFunc   ;==>_LoWord

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Wow, thank you for such a quick response! That's exactly what I needed. Now I just gotta study it so I can learn it!

Share this post


Link to post
Share on other sites

Wow, thank you for such a quick response! That's exactly what I needed. Now I just gotta study it so I can learn it!

yw, let me know if you have problems with understanding it, will help where I can.


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Wow, thank you for such a quick response! That's exactly what I needed. Now I just gotta study it so I can learn it!

Why do you have $dd greyed out? That means the height field can't be set:

;GUICtrlSetState($dd, $GUI_DISABLE)                ;Greys out Control

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

Share this post


Link to post
Share on other sites

Well, the height is the difference between the top of structure and the invert of structure. So to avoid user error by incorrectly subtracting, I would like to get autoit to automatically find the height and input it. Since I don't have that working yet the Height is greyed out. Although I guess I wouldn't need it as an input if I get autoit to do it.

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