找回密码
 加入
搜索
查看: 2534|回复: 2

[AU3基础] 求教GUICtrlCreateTreeViewItem最后一笔无法选上的问题

[复制链接]
发表于 2015-8-19 11:27:40 | 显示全部楼层 |阅读模式
求教各位前辈,

小弟尝试使用两种方式显示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
发表于 2015-8-19 18:14:24 | 显示全部楼层
搞不定,恍然大悟,学习了
 楼主| 发表于 2015-8-19 22:25:32 | 显示全部楼层
(左侧checkbox+Btn_1功能正常,目的是与右侧功能比较使用)

抱歉打错字,修正为 Btn_1....
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-28 20:12 , Processed in 0.208256 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表