anunes Posted February 27, 2009 Share Posted February 27, 2009 (edited) Hi, I've made a form with two Combos, but what is appear in first combo depends of what is selected on the second combo, so the problem is, how do to script keep checking what is the choice of second combo, to change the first combo. Here's the GUI: ;~ ********************************************************************************* ;~ Referente ao form Data ;~ ********************************************************************************* $formData = GUICreate("Data", 391, 317, 194, 126) $comboDiaInicial = GUICtrlCreateCombo("", 32, 85, 41, 25) $comboMesInicial = GUICtrlCreateCombo("", 80, 85, 137, 25) GUICtrlSetData(-1, "Janeiro|Fevereiro|Março|Abril|Maio|Junho|Julho|Agosto|Setembro|Outubro|Novembro|Dezembro|", "") $inputAnoInicial = GUICtrlCreateInput(@YEAR, 224, 85, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER)) GUICtrlSetLimit(-1, 4) $labelDataInicial = GUICtrlCreateLabel("Selecione abaixo a data inicial", 24, 24, 147, 17) $labelDataFinal = GUICtrlCreateLabel("Selecione abaixo a data final", 32, 147, 140, 17) $comboDiaFinal = GUICtrlCreateCombo("", 32, 208, 41, 25) $comboMesFinal = GUICtrlCreateCombo("", 80, 208, 137, 25) GUICtrlSetData(-1, "Janeiro|Fevereiro|Março|Abril|Maio|Junho|Julho|Agosto|Setembro|Outubro|Novembro|Dezembro", "") $botaoOK = GUICtrlCreateButton("&OK", 86, 264, 75, 25, 0) $botaoCancelar = GUICtrlCreateButton("&Cancelar", 214, 264, 75, 25, 0) #EndRegion ### END Koda GUI section ### GUISetState(@SW_SHOW, $formData)oÝ÷ Øuæºw-í¢IèÂ0í¬±é^r׶§ën®{&y«-®)àÂ+a¶k+(~Øb²j'¶§B¶¹RzÐÚµ7éÊ&nè®fêÞßÛ-çîÆ®¶sdgVæ2ôF4FôÖW2b33c¶æôFFòÂb33c¶ÖW4FFò²vWBöæRV"æBöæRÖöçF Æö6Âb33c¶Ò Æö6Âb33c·Ò Æö6Âb33c¶F4FôÖW2Òb33c¶fײgV÷C·ÂgV÷C° f÷"b33c¶ÒFòôFFTF4äÖöçFb33c¶æôFFòÂb33c¶ÖW4FFòÒ b33c¶F4FôÖW2Òõ7G&ætç6W'Bb33c¶F4FôÖW2ÂgV÷C·ÂgV÷C²fײb33c¶²Âb33c·²²w&FR7G&ærâwV7G&Ç6WFFFb33c¶6öÖ&òf÷&Ö@ bb33c¶fÇC²FVà b33c·Òb33c·² VÇ6P b33c·Òb33c·²0 VæD` æW@ &WGW&âb33c¶F4FôÖW0¤VæDgVæ2³ÒfwC²ôF4FôÖW Example: If I call _DiasDoMes(2009, 2) the func returns me the follow string: 1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28| What I want is do a loop who keep checking what is the month selected, so changing the days of this month! Some way to keep checking what was the choice on the month combo until the OK button be press! Sorry about the bad english, please, if you don't undertood something, ask me. Thanks Edited February 27, 2009 by anunes Link to comment Share on other sites More sharing options...
KaFu Posted February 27, 2009 Share Posted February 27, 2009 expandcollapse popup#include <GUIConstantsEx.au3> #include <windowsconstants.au3> #include <EditConstants.au3> #include <Date.au3> #include <String.au3> Opt("GUIOnEventMode", 1) ;~ ********************************************************************************* ;~ Referente ao form Data ;~ ********************************************************************************* $formData = GUICreate("Data", 391, 317, 194, 126) GUISetOnEvent($GUI_EVENT_CLOSE, "_exit") $comboDiaInicial = GUICtrlCreateCombo("", 32, 85, 41, 25) $comboMesInicial = GUICtrlCreateCombo("", 80, 85, 137, 25) GUICtrlSetData(-1, "Janeiro|Fevereiro|Março|Abril|Maio|Junho|Julho|Agosto|Setembro|Outubro|Novembro|Dezembro", "Janeiro") GUICtrlSetOnEvent(-1,"select_month") $inputAnoInicial = GUICtrlCreateInput(@YEAR, 224, 85, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER)) GUICtrlSetLimit(-1, 4) $labelDataInicial = GUICtrlCreateLabel("Selecione abaixo a data inicial", 24, 24, 147, 17) $labelDataFinal = GUICtrlCreateLabel("Selecione abaixo a data final", 32, 147, 140, 17) $comboDiaFinal = GUICtrlCreateCombo("", 32, 208, 41, 25) $comboMesFinal = GUICtrlCreateCombo("", 80, 208, 137, 25) GUICtrlSetData(-1, "Janeiro|Fevereiro|Março|Abril|Maio|Junho|Julho|Agosto|Setembro|Outubro|Novembro|Dezembro", "") $botaoOK = GUICtrlCreateButton("&OK", 86, 264, 75, 25, 0) $botaoCancelar = GUICtrlCreateButton("&Cancelar", 214, 264, 75, 25, 0) #EndRegion ### END Koda GUI section ### GUISetState(@SW_SHOW, $formData) select_month() while 1 WEnd func select_month() $aMonth = StringSplit("Janeiro|Fevereiro|Março|Abril|Maio|Junho|Julho|Agosto|Setembro|Outubro|Novembro|Dezembro","|") $year = GUICtrlRead($inputAnoInicial) $month = GUICtrlRead($comboMesInicial) for $i = 1 to $aMonth[0] ConsoleWrite($month & @tab & $aMonth[$i] & @crlf) if $month = $aMonth[$i] then GUICtrlSetData($comboDiaInicial,"") GUICtrlSetData($comboDiaInicial,_DiasDoMes("2009", $i),1) endif Next EndFunc Func _DiasDoMes($anoDado, $mesDado); Get the one year and one month Local $i = 1 Local $x = 0 Local $diasDoMes = $i & "|" For $i = 1 To _DateDaysInMonth($anoDado, $mesDado) - 1 $diasDoMes = _StringInsert($diasDoMes, "|" & $i + 1, $x + 1); Write a string in GUICtrlSetData($combo) format. If $i < 9 Then $x = $x + 2 Else $x = $x + 3 EndIf Next Return $diasDoMes EndFunc;=> _DiasDoMes func _exit() Exit EndFunc OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
anunes Posted February 27, 2009 Author Share Posted February 27, 2009 (edited) expandcollapse popup#include <GUIConstantsEx.au3> #include <windowsconstants.au3> #include <EditConstants.au3> #include <Date.au3> #include <String.au3> Opt("GUIOnEventMode", 1) ;~ ********************************************************************************* ;~ Referente ao form Data ;~ ********************************************************************************* $formData = GUICreate("Data", 391, 317, 194, 126) GUISetOnEvent($GUI_EVENT_CLOSE, "_exit") $comboDiaInicial = GUICtrlCreateCombo("", 32, 85, 41, 25) $comboMesInicial = GUICtrlCreateCombo("", 80, 85, 137, 25) GUICtrlSetData(-1, "Janeiro|Fevereiro|Março|Abril|Maio|Junho|Julho|Agosto|Setembro|Outubro|Novembro|Dezembro", "Janeiro") GUICtrlSetOnEvent(-1,"select_month") $inputAnoInicial = GUICtrlCreateInput(@YEAR, 224, 85, 121, 21, BitOR($ES_AUTOHSCROLL,$ES_NUMBER)) GUICtrlSetLimit(-1, 4) $labelDataInicial = GUICtrlCreateLabel("Selecione abaixo a data inicial", 24, 24, 147, 17) $labelDataFinal = GUICtrlCreateLabel("Selecione abaixo a data final", 32, 147, 140, 17) $comboDiaFinal = GUICtrlCreateCombo("", 32, 208, 41, 25) $comboMesFinal = GUICtrlCreateCombo("", 80, 208, 137, 25) GUICtrlSetData(-1, "Janeiro|Fevereiro|Março|Abril|Maio|Junho|Julho|Agosto|Setembro|Outubro|Novembro|Dezembro", "") $botaoOK = GUICtrlCreateButton("&OK", 86, 264, 75, 25, 0) $botaoCancelar = GUICtrlCreateButton("&Cancelar", 214, 264, 75, 25, 0) #EndRegion ### END Koda GUI section ### GUISetState(@SW_SHOW, $formData) select_month() while 1 WEnd func select_month() $aMonth = StringSplit("Janeiro|Fevereiro|Março|Abril|Maio|Junho|Julho|Agosto|Setembro|Outubro|Novembro|Dezembro","|") $year = GUICtrlRead($inputAnoInicial) $month = GUICtrlRead($comboMesInicial) for $i = 1 to $aMonth[0] ConsoleWrite($month & @tab & $aMonth[$i] & @crlf) if $month = $aMonth[$i] then GUICtrlSetData($comboDiaInicial,"") GUICtrlSetData($comboDiaInicial,_DiasDoMes("2009", $i),1) endif Next EndFunc Func _DiasDoMes($anoDado, $mesDado); Get the one year and one month Local $i = 1 Local $x = 0 Local $diasDoMes = $i & "|" For $i = 1 To _DateDaysInMonth($anoDado, $mesDado) - 1 $diasDoMes = _StringInsert($diasDoMes, "|" & $i + 1, $x + 1); Write a string in GUICtrlSetData($combo) format. If $i < 9 Then $x = $x + 2 Else $x = $x + 3 EndIf Next Return $diasDoMes EndFunc;=> _DiasDoMes func _exit() Exit EndFunc Thank you very much. Edited February 27, 2009 by anunes 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