Sign in to follow this  
Followers 0
sandin

case... to... clarify it for me plz

2 posts in this topic

if I have an array control, how can I detect current array that has been clicked?

example script:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 164, 253, 193, 125)
dim $checkbox1[11]
dim $checkbox2[11]
$height = 10
for $i = 1 to 10
    $checkbox1[$i] = GUICtrlCreateCheckbox("", 5, $height, 17, 17)
    $height += 17
Next
$height = 10
for $i = 1 to 10
    $checkbox2[$i] = GUICtrlCreateCheckbox("", 45, $height, 17, 17)
    _check_checkbox($checkbox2[$i], $checkbox1[$i])
    $height += 17
Next
GUISetState(@SW_SHOW)
func _check_checkbox($i_chk2, $i_chk1)
    if GUICtrlRead($i_chk1) = $GUI_CHECKED Then
        GUICtrlSetState($i_chk2, $GUI_ENABLE)
    Else
        GUICtrlSetState($i_chk2, $GUI_DISABLE)
    endif
EndFunc
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        case $checkbox1[1] to $checkbox1[10]
            _check_checkbox($checkbox2[$i], $checkbox1[$i]) ;<--- what should I type here? How could I retrieve $i (curent array)?
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites



sry, solved

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 164, 253, 193, 125)
dim $checkbox1[11]
dim $checkbox2[11]
$height = 10
for $i = 1 to 10
    $checkbox1[$i] = GUICtrlCreateCheckbox("", 5, $height, 17, 17)
    $height += 17
Next
$height = 10
for $i = 1 to 10
    $checkbox2[$i] = GUICtrlCreateCheckbox("", 45, $height, 17, 17)
    _check_checkbox($checkbox2[$i], $checkbox1[$i])
    $height += 17
Next
GUISetState(@SW_SHOW)
func _check_checkbox($i_chk2, $i_chk1)
    if GUICtrlRead($i_chk1) = $GUI_CHECKED Then
        GUICtrlSetState($i_chk2, $GUI_ENABLE)
    Else
        GUICtrlSetState($i_chk2, $GUI_DISABLE)
    endif
EndFunc
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        case $checkbox1[1] to $checkbox1[10]
            _check_checkbox($checkbox2[$nMsg-2], $checkbox1[$nMsg-2])
    EndSwitch
WEnd

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