Jump to content

Dynamically update a guictrl from another one


jmg39926
 Share

Recommended Posts

I am going to over simplify what i am try to accomplish.

I have a combo box  with all the states states CA, IN, WI, NY, etc

i have a case stmt 

case CA, NV, AZ --> region  is set to West 

Case IN, WI, IL -->  region  is set to Midwest

Case FL, GA, MS -> region is set to South

etc etc

When the state is entered it needs to display the region.  It only display's the region AFTER the OK button is pressed. Is there a way to update the region value without having to press OK.

why am i doing this...... there is another case stmt

case region = West ==>> do something west

case region = East ==>> do something east

etc. etc

 

 

$EZForm = GUICreate("Branch EZ", 596, 400, -1, -1)


$LabelFacCode= GUICtrlCreateLabel("Code:", 120, 178, 186, 25)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$comboFacCode = GUICtrlCreatecombo("Select Site", 218, 175, 95, 25)
GUICtrlSetData(-1, "|AHD|AHH|ARO|BAR|BMA|BMC|CCD|CGH|CHM|CSK|CSM|   |")
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")


$ezheader = GUICtrlCreatelabel("ez branch:", 340, 178, 90, 25)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
$ez = GUICtrlCreateCombo("", 425, 178, 150, 25, $CBS_DROPDOWNLIST)
GUICtrlSetData($ez,"Branch 1|Branch 2|Branch 3|Branch 4", "My Branch")

$Button1 = GUICtrlCreateButton("Continue", 250, 340, 107, 49)
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
        Exit
     Case $Button1
    
        $FacCode = (GUICtrlRead($ComboFacCode))
        
    ; Only do once to set the default based on fac code
        if $EZcheck = 0 then _SetDefaultEZ()
            
    ; set the actual EZ this allows them to change the default        
        if $EZcheck = 1 Then $EZData =(GUICtrlRead($EZ))

    $Check = MsgBox(1, "Header","OK to Continue - Cancel to reenter values")
              
         If   ($check =1 ) Then
            _SetEZ()
            Exit
            EndIf
                
    EndSwitch
WEnd


Func _SetDefaultEZ()
    $EZcheck = 1
Select
    Case $FacCode = "AHD" or "AHH" or "ARO"
        $EZData="Branch 1"
            GUICtrlSetData($EZ,$EZData)
    Case $FacCode = "BAR" or "BMA"
            $EZData="Branch 2"
            GUICtrlSetData($EZ,$EZData)
    Case $FacCode = "CCD" or "cGH"
            $EZData="Branch 3"
            GUICtrlSetData($EZ,$EZData)
    Case $FacCode = "CHM" or "CSK" or "CSM"
            $EZData="Branch 4"
            GUICtrlSetData($EZ,$EZData)            
EndSelect    

EndFunc

Func _SetEZ()
Select
    Case $EZData="Branch 1"
        MsgBox(64, "b1", "Branch 1 junk here: " & $EZData)
    Case $EZData="Branch 2"
        MsgBox(64, "b2","Branch 2 junk here: " & $EZData)
    Case $EZData="Branch 3"
        MsgBox(64, "b3","Branch 3 junk here: " & $EZData)
    Case $EZData="Branch 4"
        MsgBox(64, "b4","Branch 4 junk here: " & $EZData)            
EndSelect    
    
  EndFunc

The code works fine with out any issues. - but it only happens AFTER the OK button is pressed

i want to as soon as the state is entered populate the region without having to press  ok or continue.

It does not even have to be that complicated -- if user enters Y - display YES in another guictrl. 

 

Thanks for your time,

 

 

 

 

 

Edited by jmg39926
added code
Link to comment
Share on other sites

Yes there is notifications that are sent to windows that will enable you to react on mostly all moves from the user.  But it is greatly helping us if you could provide a runable script that we could use to show you how to do things.  So please provide a runable script that we will use, and we will modify to fit your requirements.

Please use tags when you post code as described in this link

Edited by Nine
Link to comment
Share on other sites

Maybe something like, the following or you could a 2 dimensional array and use the index to select the value within the array.

#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

    GUICreate("Branch EZ", 425, 50)
    GUICtrlCreateLabel("Code:", 10, 10, 80, 25, $SS_CENTERIMAGE)
        GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    Global $g_idFacCode = GUICtrlCreatecombo("Select Site", 90, 10, 105, 25, $CBS_DROPDOWNLIST)
        GUICtrlSetData($g_idFacCode, "AHD|AHH|ARO|BAR|BMA|BMC|CCD|CGH|CHM|CSK|CSM", "Select Site")
        GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")

    GUICtrlCreatelabel("ez branch:", 205, 10, 100, 25, $SS_CENTERIMAGE)
        GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    Global $g_idEZ = GUICtrlCreateCombo("", 310, 10, 105, 25, $CBS_DROPDOWNLIST)
        GUICtrlSetData($g_idEZ,"Branch 1|Branch 2|Branch 3|Branch 4", "My Branch")
        GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    GUISetState(@SW_SHOW)
    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $g_idFacCode
            _SetDefaultEZ(GUICtrlRead($g_idFacCode))
            _SetEZ(GUICtrlRead($g_idEZ))
    EndSwitch
WEnd

Func _SetDefaultEZ($_sFacCode)
    Select
        Case $_sFacCode = "AHD" or $_sFacCode = "AHH" or $_sFacCode = "ARO"
            $_sEZData="Branch 1"
        Case $_sFacCode = "BAR" or $_sFacCode = "BMA"
            $_sEZData="Branch 2"
        Case $_sFacCode = "CCD" or $_sFacCode = "cGH"
            $_sEZData="Branch 3"
        Case $_sFacCode = $_sFacCode = "CHM" or $_sFacCode = "CSK" or $_sFacCode = "CSM"
            $_sEZData="Branch 4"
    EndSelect
    GUICtrlSetData($g_idEZ,$_sEZData)
EndFunc

Func _SetEZ($_sEZData)
    Switch $_sEZData
        Case "Branch 1"
            MsgBox(64, "b1", "Branch 1 junk here: " & $_sEZData)
        Case "Branch 2"
            MsgBox(64, "b2","Branch 2 junk here: " & $_sEZData)
        Case "Branch 3"
            MsgBox(64, "b3","Branch 3 junk here: " & $_sEZData)
        Case "Branch 4"
            MsgBox(64, "b4","Branch 4 junk here: " & $_sEZData)
    EndSwitch
EndFunc

 

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...