Sign in to follow this  
Followers 0
HockeyFan

GUI Combo Box Help

7 posts in this topic

Hello!

Could someone assist me with how to change a Combo Box back to the default value when the GUI is set to disabled?

The basic idea of the script is to select a city (radio button) but if the "checkbox" is selected, all readio buttons are disabled and the Combo Box becomes enabled. If the "checkbox" is then unselected, all radio buttons become enabled and the Combo Box is set to disabled. What I need assistance with is resetting the Combo Box back to the default "Select State" value upon being disabled. I'm doing it this way because I have the GUI "OK" button become enabled upon the Combo Box selection.

Here is the code as I have it so far...

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

HotKeySet("+!t", "_Quit") ;Shift-Alt-t
Opt("GuiOnEventMode", 1)

$CityState = "Akron, OH/akr:" & _
"Albany, NY/alb:" & _
"Albuquerque, NM/alb:" & _
"Alexandria, VA/alx:" & _
"Amherst, NY/amh:" & _
"Anchorage, AK/anc:" & _
"Atlanta, GA/atl:" & _
"Austin, TX/aus:" & _
"Bala Cynwyd, PA/bcy:" & _
"Baltimore, MD/bal:" & _
"Baton Rouge, LA/bat:" & _
"Bentonville, AR/ben:" & _
"Bethlehem, PA/bet:" & _
"Billings, MT/bil:" & _
"Bingham Farms, MI/bgf:" & _
"Birmingham, AL/bir:" & _
"Boston, MA/bos:" & _
"Bridgewater, NJ/bri:" & _
"Cedar Rapids, IA/cdr:" & _
"Charlotte, NC/chr:" & _
"Chesapeake, VA/che:" & _
"Chicago, IL/chi:" & _
"Cincinnati, OH/cin:" & _
"Columbia, SC/col:" & _
"Columbus, OH/col:" & _
"Corpus Christi, TX/cor:" & _
"Dallas, TX/dal:" & _
"Decatur, IL/dec:" & _
"Denver, CO/den:" & _
"East Syracuse, NY/syr:" & _
"Emeryville, CA/emv:" & _
"Eugene, OR/eug:" & _
"Evansville,IN/evn:" & _
"Everett, WA/eve:" & _
"Fairfax, VA/ffx:" & _
"Fargo, ND/far:" & _
"Fort Lauderdale, FL/ftl:" & _
"Fort Worth, TX/ftw:" & _
"Fresno, CA/frs:" & _
"Grand Rapids, MI/gra:" & _
"Greenville, SC/gre:" & _
"Harrisburg, PA/har:" & _
"Honolulu, HI/hon:" & _
"Houston, TX/hou:" & _
"Huntsville, AL/hun:" & _
"Independence, OH/ind:" & _
"Indianapolis, IN/ind:" & _
"(Editorial Ofc.) Indianapolis, IN/edi:" & _
"Jackson, MS/jck:" & _
"Jacksonville, FL/jac:" & _
"Knoxville, TN/knx:" & _
"Las Vegas, NV/las:" & _
"Lexington, KY/lex:" & _
"Little Rock, AR/ltr:" & _
"Los Angeles, CA/los:" & _
"Louisville, KY/lou:" & _
"Lubbock, TX/lub:" & _
"Maitland, FL/mtl:" & _
"Manchester, NH/man:" & _
"Manona, WI/man:" & _
"McAllen, TX/mca:" & _
"Melville, NY/mel:" & _
"Memphis, TN/mem:" & _
"Miami, FL/mia:" & _
"Middletown, CT/mid:" & _
"Midland, TX/mid:" & _
"Minneapolis, MN/stl:" & _
"Nashville, TN/nsh:" & _
"New Orleans, LA/new:" & _
"New York, NY/nyc:" & _
"Oklahoma City, OK/okl:" & _
"Omaha, NE/oma:" & _
"Overland Park, KS/ovr:" & _
"Pensacola, FL/pen:" & _
"Phoenix, AZ/phx:" & _
"Pittsburgh, PA/pit:" & _
"Portland, OR/por:" & _
"Portland, ME/por:" & _
"Providence, RI/pro:" & _
"Raleigh, NC/ral:" & _
"Richland, WA/ric:" & _
"Richmond, VA/ric:" & _
"Rochester, NY/roc:" & _
"Sacramento, CA/sac:" & _
"Salisbury, MD/sal:" & _
"Salt Lake City, UT/slc:" & _
"San Antonio, TX/san:" & _
"San Diego, CA/sad:" & _
"San Jose, CA/saj:" & _
"Santa Ana, CA/ana:" & _
"Savannah, GA/svh:" & _
"Seattle, WA/sea:" & _
"Spokane, WA/spo:" & _
"Springfield, MO/spr:" & _
"St. Louis, MO/stl:" & _
"Tampa, FL/tam:" & _
"Tucson, AZ/tuc:" & _
"Tulsa, OK/tul:" & _
"Urbandale, IA/urb:" & _
"Utica, NY/uti:" & _
"Washington, DC/was:" & _
"Wawatosa, WI/waw:" & _
"White Plains, NY/whi:" & _
"Wichita, KS/wic:" & _
"Wilmington, DE/wil"

Global $aList[53]
$aList[0] = "|Select State|"
$aList[1] = "|Alabama|AL"
$aList[2] = "|Alaska|AK"
$aList[3] = "|Arizona|AZ"
$aList[4] = "|Arkansas|AR"
$aList[5] = "|California|CA"
$aList[6] = "|Colorado|CO"
$aList[7] = "|Connecticut|CT"
$aList[8] = "|Delaware|DE"
$aList[9] = "|District of Columbia|DC"
$aList[10] = "|Florida|FL"
$aList[11] = "|Georgia|GA"
$aList[12] = "|Hawaii|HI"
$aList[13] = "|Idaho|ID"
$aList[14] = "|Illinois|IL"
$aList[15] = "|Indiana|IN"
$aList[16] = "|Iowa|IA"
$aList[17] = "|Kansas|KS"
$aList[18] = "|Kentucky|KY"
$aList[19] = "|Louisiana|LA"
$aList[20] = "|Maine|ME"
$aList[21] = "|Maryland|MD"
$aList[22] = "|Massachusetts|MA"
$aList[23] = "|Michigan|MI"
$aList[24] = "|Minnesota|MN"
$aList[25] = "|Mississippi|MS"
$aList[26] = "|Missouri|MO"
$aList[27] = "|Montana|MT"
$aList[28] = "|Nebraska|NE"
$aList[29] = "|Nevada|NV"
$aList[30] = "|New Hampshire|NH"
$aList[31] = "|New Jersey|NJ"
$aList[32] = "|New Mexico|NM"
$aList[33] = "|New York|NY"
$aList[34] = "|North Carolina|NC"
$aList[35] = "|North Dakota|ND"
$aList[36] = "|Ohio|OH"
$aList[37] = "|Oklahoma|OK"
$aList[38] = "|Oregon|OR"
$aList[39] = "|Pennsylvania|PA"
$aList[40] = "|Rhode Island|RI"
$aList[41] = "|South Carolina|SC"
$aList[42] = "|South Dakota|SD"
$aList[43] = "|Tennessee|TN"
$aList[44] = "|Texas|TX"
$aList[45] = "|Utah|UT"
$aList[46] = "|Vermont|VT"
$aList[47] = "|Virginia|VA"
$aList[48] = "|Washington|WA"
$aList[49] = "|West Virginia|WV"
$aList[50] = "|Wisconsin|WI"
$aList[51] = "|Wyoming|WY"
$aList[52] = "|Select State|"

$CityArrayData = StringSplit($CityState, ":")
Global $Radios[$CityArrayData[0] + 1] = [$CityArrayData[0]] ; [0] = count
Global $CityID[$CityArrayData[0] + 1] = [$CityArrayData[0]] ; [0] = count

$CityNameGUI = GUICreate("", 775, 676, -1, -1, BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE))
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")
$CityNameLabel1 = GUICtrlCreateLabel("Please select the city where the computer is to be located:", 25, 8, 500, 25, $SS_CENTERIMAGE)
GUICtrlSetFont(-1, 12, 800, 0, "Arial")
GUICtrlSetColor(-1, 0x0000ff) ;Blue

$CityNameGroup1 = GUICtrlCreateGroup("", 24, 32, 725, 468)

Global $iX = 50 ; Starting X-pos
Global $iY = 50 ; Starting Y-pos

For $aX = 1 To $Radios[0]
$Radios[$aX] = GUICtrlCreateRadio(StringTrimRight($CityArrayData[$aX], 4), $iX, $iY, 160, 17)
GUICtrlSetOnEvent(-1, "CityNameSelectOKButtonEnable")
$CityID[$aX] = $CityArrayData[$aX]
$iY += 16
If Mod($aX, 27) = 0 Then
; Start new column (26 items per column)
$iY = 50
$iX += 175
EndIf
Next

GUICtrlCreateGroup("", -99, -99, 1, 1)

$HomeBasedUserCheckBox = GUICtrlCreateCheckbox(" ", 130, 512)
GUICtrlSetOnEvent(-1, "_HBUCheckBoxAction")
GUICtrlCreateLabel ('Check here if the system is to be configured for a "Home Based" User', 153, 515 , 500 , 22)
GUICtrlSetFont(-1, 11, 800, 0, "Arial")
GUICtrlSetColor(-1, 0xff0000) ;Red

$HomeBasedUserStateLabel = GUICtrlCreateLabel ('Please select the State in which the "Home Based User" resides:  ', 130, 550 , 410 , 22)
GUICtrlSetFont(-1, 10, 800, 0, "Arial")
;GUICtrlSetColor(-1, 0xff0000) ;Red
GUICtrlSetState ($HomeBasedUserStateLabel, $GUI_DISABLE)

$HomeBasedUserComboBox = GUICtrlCreateCombo("", 550, 550, 125, 25, BitOR($GUI_SS_DEFAULT_COMBO,$CBS_DROPDOWNLIST))
GUICtrlSetOnEvent(-1, "_EnableCityStateOKButton")
$sList = "|"
For $i = 0 To UBound($aList) -1
    $aSplit = StringSplit($aList[$i], "|")
    $sList &= $aSplit[2] & "|"
Next
GUICtrlSetData($HomeBasedUserComboBox, $sList, "Select State")
GUICtrlSetState ($HomeBasedUserComboBox, $GUI_DISABLE)

$CityNameButton = GUICtrlCreateButton("OK", 330, 590, 115, 35)
GUICtrlSetFont(-1, 12, 800, 0, "Arial")
GUICtrlSetOnEvent(-1, "_CityOKButtonclick")
GUICtrlSetState($CityNameButton, $GUI_DISABLE)

GUISetState()

While 1
Sleep(10)
WEnd

Func CityNameSelectOKButtonEnable()
ConsoleWrite("Debug: Clicked a radio: ID = " & @GUI_CtrlId & "; Text = " & ControlGetText(@GUI_WinHandle, "", @GUI_CtrlId) & @LF)
GUICtrlSetState($CityNameButton, $GUI_ENABLE)
EndFunc ;==>CityNameSelectOKButtonEnable

Func _Quit()
Exit
EndFunc ;==>_Quit

Func _CityOKButtonclick()
For $n = 1 To $Radios[0]
If ControlCommand($CityNameGUI, "", $Radios[$n], "IsChecked") Then
  MsgBox(64, "OK", "ID: " & $Radios[$n] & "; Text: " & ControlGetText($CityNameGUI, "", $Radios[$n]))
  ExitLoop
EndIf
Next
$HBUComboRead = GUICtrlRead($HomeBasedUserComboBox)
If ControlCommand($CityNameGUI, "", $HomeBasedUserComboBox, "IsEnabled") Then
  MsgBox(64, "State", "State: " & $HBUComboRead)
EndIf

GUICtrlSetState($CityNameButton, $GUI_DISABLE)
Call ("_Quit")
EndFunc ;==>_CityOKButtonclick

Func _HBUCheckBoxAction()
GUICtrlSetState($CityNameButton, $GUI_DISABLE)
If BitAND(GUICtrlRead($HomeBasedUserCheckBox), $GUI_CHECKED) = $GUI_CHECKED Then Call("_HBUMessage")
For $x = 1 To UBound($CityArrayData) - 1
If BitAND(GUICtrlRead($Radios[$x]), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState(($Radios[$x]), $GUI_UNCHECKED)
If BitAND(GUICtrlRead($HomeBasedUserCheckBox), $GUI_CHECKED) = $GUI_CHECKED Then
  GUICtrlSetState(($Radios[$x]), $GUI_DISABLE)
  GUICtrlSetState ($HomeBasedUserStateLabel, $GUI_ENABLE)
  GUICtrlSetState ($HomeBasedUserComboBox, $GUI_ENABLE)
Else
  GUICtrlSetState($CityNameButton, $GUI_DISABLE)
  If BitAND(GUICtrlRead($Radios[$x]), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState(($Radios[$x]), $GUI_UNCHECKED)
  GUICtrlSetState(($Radios[$x]), $GUI_ENABLE)
  GUICtrlSetState ($HomeBasedUserStateLabel, $GUI_DISABLE)
  GUICtrlSetState ($HomeBasedUserComboBox, $GUI_DISABLE)
  If BitAND(GUICtrlRead($HomeBasedUserComboBox), $GUI_DISABLE) = $GUI_DISABLE Then GUICtrlSetData($HomeBasedUserComboBox, $sList, "Select State")
EndIf
Next
;GUIDelete($CityNameGUI)
EndFunc

Func _HBUMessage()
MsgBox(262208,"Please Read!","PLEASE NOTE: " & @CRLF & @CRLF & "Home Based Users are staff who work full-time out of their home and do not work in an office.          " & @CRLF & @CRLF & "Please verify!")
EndFunc

Func _EnableCityStateOKButton()
If GUICtrlRead ($HomeBasedUserComboBox) <> "Select State" Then GUICtrlSetState($CityNameButton, $GUI_ENABLE)
If GUICtrlRead ($HomeBasedUserComboBox) = "Select State" Then GUICtrlSetState($CityNameButton, $GUI_DISABLE)
EndFunc

Share this post


Link to post
Share on other sites



HockeyFan,

Just refill the combo if the checkbox is unchecked - I have made a small function to do this as you can see (look for the <<<<<<<< lines): :(

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

HotKeySet("+!t", "_Quit") ;Shift-Alt-t
Opt("GuiOnEventMode", 1)

$CityState = "Akron, OH/akr:" & _
        "Albany, NY/alb:" & _
        "Albuquerque, NM/alb:" & _
        "Alexandria, VA/alx:" & _
        "Amherst, NY/amh:" & _
        "Anchorage, AK/anc:" & _
        "Atlanta, GA/atl:" & _
        "Austin, TX/aus:" & _
        "Bala Cynwyd, PA/bcy:" & _
        "Baltimore, MD/bal:" & _
        "Baton Rouge, LA/bat:" & _
        "Bentonville, AR/ben:" & _
        "Bethlehem, PA/bet:" & _
        "Billings, MT/bil:" & _
        "Bingham Farms, MI/bgf:" & _
        "Birmingham, AL/bir:" & _
        "Boston, MA/bos:" & _
        "Bridgewater, NJ/bri:" & _
        "Cedar Rapids, IA/cdr:" & _
        "Charlotte, NC/chr:" & _
        "Chesapeake, VA/che:" & _
        "Chicago, IL/chi:" & _
        "Cincinnati, OH/cin:" & _
        "Columbia, SC/col:" & _
        "Columbus, OH/col:" & _
        "Corpus Christi, TX/cor:" & _
        "Dallas, TX/dal:" & _
        "Decatur, IL/dec:" & _
        "Denver, CO/den:" & _
        "East Syracuse, NY/syr:" & _
        "Emeryville, CA/emv:" & _
        "Eugene, OR/eug:" & _
        "Evansville,IN/evn:" & _
        "Everett, WA/eve:" & _
        "Fairfax, VA/ffx:" & _
        "Fargo, ND/far:" & _
        "Fort Lauderdale, FL/ftl:" & _
        "Fort Worth, TX/ftw:" & _
        "Fresno, CA/frs:" & _
        "Grand Rapids, MI/gra:" & _
        "Greenville, SC/gre:" & _
        "Harrisburg, PA/har:" & _
        "Honolulu, HI/hon:" & _
        "Houston, TX/hou:" & _
        "Huntsville, AL/hun:" & _
        "Independence, OH/ind:" & _
        "Indianapolis, IN/ind:" & _
        "(Editorial Ofc.) Indianapolis, IN/edi:" & _
        "Jackson, MS/jck:" & _
        "Jacksonville, FL/jac:" & _
        "Knoxville, TN/knx:" & _
        "Las Vegas, NV/las:" & _
        "Lexington, KY/lex:" & _
        "Little Rock, AR/ltr:" & _
        "Los Angeles, CA/los:" & _
        "Louisville, KY/lou:" & _
        "Lubbock, TX/lub:" & _
        "Maitland, FL/mtl:" & _
        "Manchester, NH/man:" & _
        "Manona, WI/man:" & _
        "McAllen, TX/mca:" & _
        "Melville, NY/mel:" & _
        "Memphis, TN/mem:" & _
        "Miami, FL/mia:" & _
        "Middletown, CT/mid:" & _
        "Midland, TX/mid:" & _
        "Minneapolis, MN/stl:" & _
        "Nashville, TN/nsh:" & _
        "New Orleans, LA/new:" & _
        "New York, NY/nyc:" & _
        "Oklahoma City, OK/okl:" & _
        "Omaha, NE/oma:" & _
        "Overland Park, KS/ovr:" & _
        "Pensacola, FL/pen:" & _
        "Phoenix, AZ/phx:" & _
        "Pittsburgh, PA/pit:" & _
        "Portland, OR/por:" & _
        "Portland, ME/por:" & _
        "Providence, RI/pro:" & _
        "Raleigh, NC/ral:" & _
        "Richland, WA/ric:" & _
        "Richmond, VA/ric:" & _
        "Rochester, NY/roc:" & _
        "Sacramento, CA/sac:" & _
        "Salisbury, MD/sal:" & _
        "Salt Lake City, UT/slc:" & _
        "San Antonio, TX/san:" & _
        "San Diego, CA/sad:" & _
        "San Jose, CA/saj:" & _
        "Santa Ana, CA/ana:" & _
        "Savannah, GA/svh:" & _
        "Seattle, WA/sea:" & _
        "Spokane, WA/spo:" & _
        "Springfield, MO/spr:" & _
        "St. Louis, MO/stl:" & _
        "Tampa, FL/tam:" & _
        "Tucson, AZ/tuc:" & _
        "Tulsa, OK/tul:" & _
        "Urbandale, IA/urb:" & _
        "Utica, NY/uti:" & _
        "Washington, DC/was:" & _
        "Wawatosa, WI/waw:" & _
        "White Plains, NY/whi:" & _
        "Wichita, KS/wic:" & _
        "Wilmington, DE/wil"

Global $aList[53]
$aList[0] = "|Select State|"
$aList[1] = "|Alabama|AL"
$aList[2] = "|Alaska|AK"
$aList[3] = "|Arizona|AZ"
$aList[4] = "|Arkansas|AR"
$aList[5] = "|California|CA"
$aList[6] = "|Colorado|CO"
$aList[7] = "|Connecticut|CT"
$aList[8] = "|Delaware|DE"
$aList[9] = "|District of Columbia|DC"
$aList[10] = "|Florida|FL"
$aList[11] = "|Georgia|GA"
$aList[12] = "|Hawaii|HI"
$aList[13] = "|Idaho|ID"
$aList[14] = "|Illinois|IL"
$aList[15] = "|Indiana|IN"
$aList[16] = "|Iowa|IA"
$aList[17] = "|Kansas|KS"
$aList[18] = "|Kentucky|KY"
$aList[19] = "|Louisiana|LA"
$aList[20] = "|Maine|ME"
$aList[21] = "|Maryland|MD"
$aList[22] = "|Massachusetts|MA"
$aList[23] = "|Michigan|MI"
$aList[24] = "|Minnesota|MN"
$aList[25] = "|Mississippi|MS"
$aList[26] = "|Missouri|MO"
$aList[27] = "|Montana|MT"
$aList[28] = "|Nebraska|NE"
$aList[29] = "|Nevada|NV"
$aList[30] = "|New Hampshire|NH"
$aList[31] = "|New Jersey|NJ"
$aList[32] = "|New Mexico|NM"
$aList[33] = "|New York|NY"
$aList[34] = "|North Carolina|NC"
$aList[35] = "|North Dakota|ND"
$aList[36] = "|Ohio|OH"
$aList[37] = "|Oklahoma|OK"
$aList[38] = "|Oregon|OR"
$aList[39] = "|Pennsylvania|PA"
$aList[40] = "|Rhode Island|RI"
$aList[41] = "|South Carolina|SC"
$aList[42] = "|South Dakota|SD"
$aList[43] = "|Tennessee|TN"
$aList[44] = "|Texas|TX"
$aList[45] = "|Utah|UT"
$aList[46] = "|Vermont|VT"
$aList[47] = "|Virginia|VA"
$aList[48] = "|Washington|WA"
$aList[49] = "|West Virginia|WV"
$aList[50] = "|Wisconsin|WI"
$aList[51] = "|Wyoming|WY"
$aList[52] = "|Select State|"

$CityArrayData = StringSplit($CityState, ":")
Global $Radios[$CityArrayData[0] + 1] = [$CityArrayData[0]] ; [0] = count
Global $CityID[$CityArrayData[0] + 1] = [$CityArrayData[0]] ; [0] = count

$CityNameGUI = GUICreate("", 775, 676, -1, -1, BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE))
GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit")
$CityNameLabel1 = GUICtrlCreateLabel("Please select the city where the computer is to be located:", 25, 8, 500, 25, $SS_CENTERIMAGE)
GUICtrlSetFont(-1, 12, 800, 0, "Arial")
GUICtrlSetColor(-1, 0x0000ff) ;Blue

$CityNameGroup1 = GUICtrlCreateGroup("", 24, 32, 725, 468)

Global $iX = 50 ; Starting X-pos
Global $iY = 50 ; Starting Y-pos

For $aX = 1 To $Radios[0]
    $Radios[$aX] = GUICtrlCreateRadio(StringTrimRight($CityArrayData[$aX], 4), $iX, $iY, 160, 17)
    GUICtrlSetOnEvent(-1, "CityNameSelectOKButtonEnable")
    $CityID[$aX] = $CityArrayData[$aX]
    $iY += 16
    If Mod($aX, 27) = 0 Then
        ; Start new column (26 items per column)
        $iY = 50
        $iX += 175
    EndIf
Next

GUICtrlCreateGroup("", -99, -99, 1, 1)

$HomeBasedUserCheckBox = GUICtrlCreateCheckbox(" ", 130, 512)
GUICtrlSetOnEvent(-1, "_HBUCheckBoxAction")
GUICtrlCreateLabel('Check here if the system is to be configured for a "Home Based" User', 153, 515, 500, 22)
GUICtrlSetFont(-1, 11, 800, 0, "Arial")
GUICtrlSetColor(-1, 0xff0000) ;Red

$HomeBasedUserStateLabel = GUICtrlCreateLabel('Please select the State in which the "Home Based User" resides:  ', 130, 550, 410, 22)
GUICtrlSetFont(-1, 10, 800, 0, "Arial")
;GUICtrlSetColor(-1, 0xff0000) ;Red
GUICtrlSetState($HomeBasedUserStateLabel, $GUI_DISABLE)

$HomeBasedUserComboBox = GUICtrlCreateCombo("", 550, 550, 125, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST))
GUICtrlSetOnEvent(-1, "_EnableCityStateOKButton")
_Combo_Fill() ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
GUICtrlSetState($HomeBasedUserComboBox, $GUI_DISABLE)

$CityNameButton = GUICtrlCreateButton("OK", 330, 590, 115, 35)
GUICtrlSetFont(-1, 12, 800, 0, "Arial")
GUICtrlSetOnEvent(-1, "_CityOKButtonclick")
GUICtrlSetState($CityNameButton, $GUI_DISABLE)

GUISetState()

While 1
    Sleep(10)
WEnd

Func CityNameSelectOKButtonEnable()
    ConsoleWrite("Debug: Clicked a radio: ID = " & @GUI_CtrlId & "; Text = " & ControlGetText(@GUI_WinHandle, "", @GUI_CtrlId) & @LF)
    GUICtrlSetState($CityNameButton, $GUI_ENABLE)
EndFunc   ;==>CityNameSelectOKButtonEnable

Func _Quit()
    Exit
EndFunc   ;==>_Quit

Func _CityOKButtonclick()
    For $n = 1 To $Radios[0]
        If ControlCommand($CityNameGUI, "", $Radios[$n], "IsChecked") Then
            MsgBox(64, "OK", "ID: " & $Radios[$n] & "; Text: " & ControlGetText($CityNameGUI, "", $Radios[$n]))
            ExitLoop
        EndIf
    Next
    $HBUComboRead = GUICtrlRead($HomeBasedUserComboBox)
    If ControlCommand($CityNameGUI, "", $HomeBasedUserComboBox, "IsEnabled") Then
        MsgBox(64, "State", "State: " & $HBUComboRead)
    EndIf

    GUICtrlSetState($CityNameButton, $GUI_DISABLE)
    Call("_Quit")
EndFunc   ;==>_CityOKButtonclick

Func _HBUCheckBoxAction()
    GUICtrlSetState($CityNameButton, $GUI_DISABLE)
    If BitAND(GUICtrlRead($HomeBasedUserCheckBox), $GUI_CHECKED) = $GUI_CHECKED Then Call("_HBUMessage")
    For $x = 1 To UBound($CityArrayData) - 1
        If BitAND(GUICtrlRead($Radios[$x]), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState(($Radios[$x]), $GUI_UNCHECKED)
        If BitAND(GUICtrlRead($HomeBasedUserCheckBox), $GUI_CHECKED) = $GUI_CHECKED Then
            GUICtrlSetState(($Radios[$x]), $GUI_DISABLE)
            GUICtrlSetState($HomeBasedUserStateLabel, $GUI_ENABLE)
            GUICtrlSetState($HomeBasedUserComboBox, $GUI_ENABLE)
        Else
            GUICtrlSetState($CityNameButton, $GUI_DISABLE)
            If BitAND(GUICtrlRead($Radios[$x]), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState(($Radios[$x]), $GUI_UNCHECKED)
            GUICtrlSetState(($Radios[$x]), $GUI_ENABLE)
            GUICtrlSetState($HomeBasedUserStateLabel, $GUI_DISABLE)
            _Combo_Fill() ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            GUICtrlSetState($HomeBasedUserComboBox, $GUI_DISABLE)
            If BitAND(GUICtrlRead($HomeBasedUserComboBox), $GUI_DISABLE) = $GUI_DISABLE Then GUICtrlSetData($HomeBasedUserComboBox, $sList, "Select State")
        EndIf
    Next
    ;GUIDelete($CityNameGUI)
EndFunc   ;==>_HBUCheckBoxAction

Func _HBUMessage()
    MsgBox(262208, "Please Read!", "PLEASE NOTE: " & @CRLF & @CRLF & "Home Based Users are staff who work full-time out of their home and do not work in an office.          " & @CRLF & @CRLF & "Please verify!")
EndFunc   ;==>_HBUMessage

Func _EnableCityStateOKButton()
    If GUICtrlRead($HomeBasedUserComboBox) <> "Select State" Then GUICtrlSetState($CityNameButton, $GUI_ENABLE)
    If GUICtrlRead($HomeBasedUserComboBox) = "Select State" Then GUICtrlSetState($CityNameButton, $GUI_DISABLE)
EndFunc   ;==>_EnableCityStateOKButton

Func _Combo_Fill() ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    $sList = "|"
    For $i = 0 To UBound($aList) - 1
        $aSplit = StringSplit($aList[$i], "|")
        $sList &= $aSplit[2] & "|"
    Next
    GUICtrlSetData($HomeBasedUserComboBox, $sList, "Select State")
EndFunc

All clear? :graduated:

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

M23,

Thank you for your help! That's such a simple solution. I guess I was making this task harder than it needed to be. But then again, that's my life...I'm a rookie!!

Another question...is there anything I can do to speed up the re-enabling of the radio buttons when the check box is deselected? The enableing of the radio buttons seems slow.

HockeyFan

Share this post


Link to post
Share on other sites

HockeyFan,

i had a feeling that might be you next question! :D

This is as fast as it will go - you do have a lot of radios: :(

Func _HBUCheckBoxAction()

    GUICtrlSetState($CityNameButton, $GUI_DISABLE)
    For $x = 1 To UBound($CityArrayData) - 1
        GUICtrlSetState($Radios[$x], $GUI_UNCHECKED)
    Next
    Switch GUICtrlRead($HomeBasedUserCheckBox)
        Case 1 ; Checked
            For $x = 1 To UBound($CityArrayData) - 1
                GUICtrlSetState($Radios[$x], $GUI_DISABLE)
            Next
            _HBUMessage() ; No need to use Call here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            GUICtrlSetState($HomeBasedUserStateLabel, $GUI_ENABLE)
            GUICtrlSetState($HomeBasedUserComboBox, $GUI_ENABLE)
        Case Else ; Not checked
            For $x = 1 To UBound($CityArrayData) - 1
                GUICtrlSetState($Radios[$x], $GUI_ENABLE)
            Next
            GUICtrlSetState($HomeBasedUserStateLabel, $GUI_DISABLE)
            _Combo_Fill()
            GUICtrlSetState($HomeBasedUserComboBox, $GUI_DISABLE)
    EndSwitch
    
EndFunc   ;==>_HBUCheckBoxAction

As you can see I used a little trick to see if the checkbox was checked and then just set all the radios to the required state rather then only the one that needed it - speeds the function up no end removing all the If BitAND lines. :graduated:

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

HockeyFan,

i had a feeling that might be you next question! :D

This is as fast as it will go - you do have a lot of radios: :(

Func _HBUCheckBoxAction()

    GUICtrlSetState($CityNameButton, $GUI_DISABLE)
    For $x = 1 To UBound($CityArrayData) - 1
        GUICtrlSetState($Radios[$x], $GUI_UNCHECKED)
    Next
    Switch GUICtrlRead($HomeBasedUserCheckBox)
        Case 1 ; Checked
            For $x = 1 To UBound($CityArrayData) - 1
                GUICtrlSetState($Radios[$x], $GUI_DISABLE)
            Next
            _HBUMessage() ; No need to use Call here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            GUICtrlSetState($HomeBasedUserStateLabel, $GUI_ENABLE)
            GUICtrlSetState($HomeBasedUserComboBox, $GUI_ENABLE)
        Case Else ; Not checked
            For $x = 1 To UBound($CityArrayData) - 1
                GUICtrlSetState($Radios[$x], $GUI_ENABLE)
            Next
            GUICtrlSetState($HomeBasedUserStateLabel, $GUI_DISABLE)
            _Combo_Fill()
            GUICtrlSetState($HomeBasedUserComboBox, $GUI_DISABLE)
    EndSwitch
    
EndFunc   ;==>_HBUCheckBoxAction

As you can see I used a little trick to see if the checkbox was checked and then just set all the radios to the required state rather then only the one that needed it - speeds the function up no end removing all the If BitAND lines. :graduated:

M23

Ahhhhhhhhh...much better. THANK YOU!!!

Share this post


Link to post
Share on other sites

@M23

You can probably speed it up even more by using the Dummy control method. Then you can just loop through the controls instead of the array.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

George,

I did try that, but the difference in speed was very marginal. So I thought it best to stick with the single changed function - using Dummy controls can seem a bit confusing and might well need more explanation than I felt like typing this evening. :(

HockeyFan,

If you are interested, I can explain what George is on about tomorrow. :graduated:

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
Sign in to follow this  
Followers 0