Kjodiz Posted September 12, 2012 Share Posted September 12, 2012 When I try to switch between two combos, the 'third' one won't follow. (It's a bit hard to explain.) I've been trying different things on them like SW_SHOW/HIDE/DISABLE etc, with no luck. And yes, I know the code is a mess, but I'll clean it up in a while expandcollapse popup#include <misc.au3> #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $bCal = GUICreate("BindingCalc", 552, 214, 192, 124) $opt = GUICtrlCreateCombo("", 24, 64, 145, 25) GUICtrlSetData(-1, "Chess|Netcom|Tele2|Ucan2") $Label1 = GUICtrlCreateLabel("Operatør", 56, 32, 75, 24) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x000000) $mnd = GUICtrlCreateCombo("", 400, 64, 49, 25) GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9|10|11|12") $Label2 = GUICtrlCreateLabel("Ant. Mnd.", 384, 32, 81, 24) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $OK = GUICtrlCreateButton("OK", 192, 144, 83, 41) $Exit = GUICtrlCreateButton("Exit", 288, 144, 83, 41) $Label3 = GUICtrlCreateLabel("Abonnement", 232, 32, 106, 24) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $Check = GUICtrlCreateButton("Check", 56, 96, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $Chess = int(250) ;================Netcom $FastS = int(63) $FastM = int(83) $FastMP = int(125) $FastL = int(187,5) $FastLP = int(187,5) $FastXL = int(190) $FastData = int(225) $Flexi = int(83) $FlexiSurf = int(125) $Young = int(150) $YoungP = int(216) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $OK $ReadA = GUICtrlRead ($abo) ;Reading AboCombo $ReadM = GUICtrlRead ($mnd) ;Reading mndCombo If $ReadA = "FastPris Small" Then ;Fast S MsgBox (0,"Sum", int($FastS) * int($ReadM)) EndIf If $ReadA = "FastPris Medium" Then ;Fast M MsgBox (0,"Sum", int($FastM) * int($ReadM)) EndIf If $ReadA = "FastPris Large" Then ;Fast L MsgBox (0,"Sum", int($FastL) * int($ReadM)) EndIf If $ReadA = "FastPris Large+" Then ;Fast L+ MsgBox (0,"Sum", int($FastLP) * int($ReadM)) EndIf If $ReadA = "FastPris XL" Then ;Fast XL MsgBox (0,"Sum", int($FastXL) * int($ReadM)) EndIf If $ReadA = "FastPris Data" Then ;Fast Data MsgBox (0,"Sum", int($FastData) * int($ReadM)) EndIf If $ReadA = "FlexiTalk" Then ;FlexiTalk MsgBox (0,"Sum", int($Flexi) * int($ReadM)) EndIf If $ReadA = "FlexiTalk Surf" Then ;Flexi Surf MsgBox (0,"Sum", int($FlexiSurf) * int($ReadM)) EndIf If $ReadA = "YoungTalk" Then ;YoungTalk MsgBox (0,"Sum", int($Young) * int($ReadM)) EndIf If $ReadA = "YoungTalk+" Then ;YoungTalk Plus MsgBox (0,"Sum", int($YoungP) * int($ReadM)) EndIf Case $Check ;Activating Abo-Combo $ReadO = GUICtrlRead ($opt) If $ReadO = "Chess" Then $abo = GUICtrlCreateCombo("", 216, 64, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetData (-1, "SjakkMatt|OnFire") GUISetState(@SW_SHOW) EndIf If $ReadO = "Netcom" Then $abo = GUICtrlCreateCombo("", 216, 64, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetData (-1, "FastPris Small|FastPris Medium|FastPris Medium+|FastPris Large|FastPris Large+|FastPris XL|FastPris Data|FlexiTalk|FlexiTalk Surf|YoungTalk|YoungTalk+") GUISetState(@SW_SHOW) EndIf Case $Exit Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
Kjodiz Posted September 12, 2012 Author Share Posted September 12, 2012 Oh, and I guess I forgot to tell that this: If $ReadO = "Chess" Then $abo = GUICtrlCreateCombo("", 216, 64, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetData (-1, "SjakkMatt|OnFire") GUISetState(@SW_SHOW) EndIf If $ReadO = "Netcom" Then $abo = GUICtrlCreateCombo("", 216, 64, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL)) GUICtrlSetData (-1, "FastPris Small|FastPris Medium|FastPris Medium+|FastPris Large|FastPris Large+|FastPris XL|FastPris Data|FlexiTalk|FlexiTalk Surf|YoungTalk|YoungTalk+") GUISetState(@SW_SHOW) EndIf is the part that's failing Link to comment Share on other sites More sharing options...
Spiff59 Posted September 12, 2012 Share Posted September 12, 2012 You're creating a new combobox control on top of the previous one each time the "check" button is clicked. Not a good practice. You should create the combobox up at the top with the rest of the GUI and just set it's state to $GUI_HIDE initially, then reset the state when you want the combo visible. You'd have to call _GUICtrlComboBox_ResetContent() to clear the combo and reload the specific values each time depending on the value of the $opt combo. Like: expandcollapse popup#include <misc.au3> #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <GuiComboBox.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $bCal = GUICreate("BindingCalc", 552, 214, 192, 124) $opt = GUICtrlCreateCombo("", 24, 64, 145, 25) GUICtrlSetData(-1, "Chess|Netcom|Tele2|Ucan2") $Label1 = GUICtrlCreateLabel("Operatør", 56, 32, 75, 24) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x000000) $mnd = GUICtrlCreateCombo("", 400, 64, 49, 25) GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9|10|11|12") $Label2 = GUICtrlCreateLabel("Ant. Mnd.", 384, 32, 81, 24) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $OK = GUICtrlCreateButton("OK", 192, 144, 83, 41) $Exit = GUICtrlCreateButton("Exit", 288, 144, 83, 41) $Label3 = GUICtrlCreateLabel("Abonnement", 232, 32, 106, 24) GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif") $abo = GUICtrlCreateCombo("", 216, 64, 145, 25) GUICtrlSetState(-1, $GUI_HIDE) $Check = GUICtrlCreateButton("Check", 56, 96, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $Chess = int(250) ;================Netcom $FastS = int(63) $FastM = int(83) $FastMP = int(125) $FastL = int(187,5) $FastLP = int(187,5) $FastXL = int(190) $FastData = int(225) $Flexi = int(83) $FlexiSurf = int(125) $Young = int(150) $YoungP = int(216) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $OK GUICtrlSetState($abo, $GUI_HIDE) ; I don't know when/where you want to rehide this combo... $ReadA = GUICtrlRead ($abo) ;Reading AboCombo $ReadM = GUICtrlRead ($mnd) ;Reading mndCombo Switch $ReadA Case "FastPris Small" ;Fast S MsgBox (0,"Sum", int($FastS) * int($ReadM)) Case "FastPris Medium" ;Fast M MsgBox (0,"Sum", int($FastM) * int($ReadM)) Case "FastPris Large" ;Fast L MsgBox (0,"Sum", int($FastL) * int($ReadM)) Case "FastPris Large+" ;Fast L+ MsgBox (0,"Sum", int($FastLP) * int($ReadM)) Case "FastPris XL" ;Fast XL MsgBox (0,"Sum", int($FastXL) * int($ReadM)) Case "FastPris Data" ;Fast Data MsgBox (0,"Sum", int($FastData) * int($ReadM)) Case "FlexiTalk" ;FlexiTalk MsgBox (0,"Sum", int($Flexi) * int($ReadM)) Case "FlexiTalk Surf" ;Flexi Surf MsgBox (0,"Sum", int($FlexiSurf) * int($ReadM)) Case "YoungTalk" ;YoungTalk MsgBox (0,"Sum", int($Young) * int($ReadM)) Case "YoungTalk+" ;YoungTalk Plus MsgBox (0,"Sum", int($YoungP) * int($ReadM)) EndSwitch Case $Check ;Activating Abo-Combo $ReadO = GUICtrlRead ($opt) If $ReadO = "Chess" Then _GUICtrlComboBox_ResetContent($abo) GUICtrlSetData ($abo, "SjakkMatt|OnFire") GUICtrlSetState($abo, $GUI_SHOW) EndIf If $ReadO = "Netcom" Then _GUICtrlComboBox_ResetContent($abo) GUICtrlSetData ($abo, "FastPris Small|FastPris Medium|FastPris Medium+|FastPris Large|FastPris Large+|FastPris XL|FastPris Data|FlexiTalk|FlexiTalk Surf|YoungTalk|YoungTalk+") GUICtrlSetState($abo, $GUI_SHOW) EndIf Case $Exit Exit EndSwitch WEnd You could also create 2 overlapping comboboxes up front and just disable/hide the one (or ones) you dont want visible, then you wouldn't have to reload the combobox values each time. You would then have to keep track of the fact that they have different control ID's when reading the combos. I'm sure there are a dozen other ways to go about it as well. Link to comment Share on other sites More sharing options...
Kjodiz Posted September 13, 2012 Author Share Posted September 13, 2012 Thanks ! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now