Jump to content

Trouble with Combo


anunes
 Share

Recommended Posts

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®{&-®)àÂ+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 by anunes
Link to comment
Share on other sites

#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

Link to comment
Share on other sites

#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 by anunes
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...