|
求教各位前辈,
小弟尝试使用两种方式显示Checkbox列表
1. GUICtrlCreateCheckbox --> 左侧checkbox+Btn_1 结果正常
2. GUICtrlCreateTreeViewItem --> 右下方checkbox+Btn_2 存在最后一笔选取的问题
目前小弟猜测是最后选取的事件没能驱动GUICtrlRead,不知道这样思考对不对?
针对右下方checkbox+Btn_2问题描述:
Step1. 右下方checkbox选取20% Duty, 40% Duty, 50% Duty
Step2. 点击Btn_2按钮
Step3. Msgbox显示被选取的 20% Duty, 40% Duty情况
Issue1 :Msgbox没有显示被选取的 50% Duty
Issue2 :倘若继续把40% Duty取消选取后执行Btn_2, 就会显示20% Duty,50 Duty (看似正常)
(左侧checkbox+Btn_2功能正常,目的是与右侧功能比较使用)
请教该如何解决GUICtrlCreateTreeViewItem在checkbox最后选取的问题?
谢谢解答#Include <File.au3>
#include <GuiConstantsEx.au3>
#include <AVIConstants.au3> ;**** GUI enssential head file ****
#include <TreeViewConstants.au3>
#include <DateTimeConstants.au3>
#include <GuiToolbar.au3>
#include <Array.au3>
Opt("GUIOnEventMode", 1)
$Mainwindow = GUICreate(" ",600,350)
GUICtrlCreateTab(0, 1, 600, 350,-1,-1) ; Width600,Height350,locate in middle of screen (-1,-1)
$tab1=GUICtrlCreateTabItem("Verify")
GUICtrlSetState(-1, $GUI_SHOW)
;Fan duty
$Fandutylabel=GUICtrlCreateLabel("Fan Duty :",210,170,130,20)
GUICtrlSetFont($Fandutylabel, 12, 400, 2,"Times New Roman")
$Fandutylist=GUICtrlCreateTreeView(210, 190, 130, 144,$TVS_CHECKBOXES)
;Close button
GUISetOnEvent($GUI_Event_Close,"CloseButton")
;Start button #1
$Btn_1=GUICtrlCreateButton("Btn_1",130,40,50,40)
GUICtrlSetOnEvent(-1, "Fandutyselect1")
;Start button #2
$Btn_2=GUICtrlCreateButton("Btn_2",415,140,50,40)
GUICtrlSetOnEvent(-1, "Fandutyselect2")
Global $Fanduty[2][101]
; Using GUICtrlCreateCheckbox
For $j = 20 to 100 Step + 10
$Fanduty[0][$j] = GUICtrlCreateCheckbox($j & "% Duty", 10, 1.8*$j, 120, 20)
Next
; Using GUICtrlCreateTreeViewItem
For $k = 20 to 100 Step + 10
$Fanduty[1][$k] = GUICtrlCreateTreeViewItem($k & "% Duty", $Fandutylist)
Next
Func Fandutyselect1()
For $j = 1 To 100
If GUICtrlRead($Fanduty[0][$j]) = $GUI_CHECKED Then
MsgBox(4096, 'Left checkbox', $j & "% Duty")
EndIf
Next
EndFunc
Func Fandutyselect2()
For $k = 1 To 100
If GUICtrlRead($Fanduty[1][$k]) = $GUI_CHECKED Then
MsgBox(4096, 'right checkbox', $k & "% Duty")
EndIf
Next
EndFunc
GUISetState(@SW_Show)
While 1
Sleep(1000)
WEnd
Func CloseButton()
Exit
EndFunc
|
|