#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiConstantsEx.au3>
#include <GuiTreeView.au3>
#include <WindowsConstants.au3>
#include <GUIListBox.au3>
;Opt('MustDeclareVars', 1)
$Debug_TV = False ; Check ClassName being passed to functions, set to True and use a handle to another control to see it work
Global $hTreeView, $List1
_Main()
Func _Main()
Global $hItem, $hImage, $iImage, $hTreeView,$nMsg,$dll
Global $GUI, $hItem,$Child0,$Child1,$Child2,$Child3,$Child4,$Child5,$Child6,$Child7,$hItem0,$hItem1
Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)
$GUI = GUICreate("(UDF Created) TreeView Create", 400, 540)
$hTreeView = _GUICtrlTreeView_Create($GUI, 2, 2, 396, 268, $iStyle, $WS_EX_CLIENTEDGE)
$List1 = GUICtrlCreateList("", 2, 277, 394, 268)
GUISetState()
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
_GUICtrlTreeView_BeginUpdate($hTreeView)
$hItem0 = _GUICtrlTreeView_Add($hTreeView, 0, "soft1", 1, 1)
$Child0=_GUICtrlTreeView_AddChild($hTreeView,$hItem0,StringFormat("%02d : Random string",0), 1, 1)
$Child1=_GUICtrlTreeView_AddChild($hTreeView,$hItem0,StringFormat("%02d : Random string",1), 1, 1)
$Child2=_GUICtrlTreeView_AddChild($hTreeView,$hItem0,StringFormat("%02d : Random string",2), 1, 1)
$Child3=_GUICtrlTreeView_AddChild($hTreeView,$hItem0,StringFormat("%02d : Random string",3), 1, 1)
$hItem1 = _GUICtrlTreeView_Add($hTreeView, 0, "soft2", 1, 1)
$Child4=_GUICtrlTreeView_AddChild($hTreeView,$hItem1,StringFormat("%02d : Random string",4), 1, 1)
$Child5=_GUICtrlTreeView_AddChild($hTreeView,$hItem1,StringFormat("%02d : Random string",5), 1, 1)
$Child6=_GUICtrlTreeView_AddChild($hTreeView,$hItem1,StringFormat("%02d : Random string",6), 1, 1)
$Child7=_GUICtrlTreeView_AddChild($hTreeView,$hItem1,StringFormat("%02d : Random string",7), 1, 1)
_GUICtrlTreeView_EndUpdate($hTreeView)
; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>_Main
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTreeview
$hWndTreeview = $hTreeView
If Not IsHWnd($hTreeView) Then $hWndTreeview = GUICtrlGetHandle($hTreeView)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndTreeview
Switch $iCode
Case $NM_CLICK
For $i = 0 To 7
If _GUICtrlTreeView_GetChecked($hTreeView,Eval("Child"&$i)) Then
_GUICtrlListBox_InsertString($List1,'准备安装:'&StringFormat("%02d : Random string",$i),$i)
Else
_GUICtrlListBox_DeleteString($List1, $i)
EndIf
Next
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
你给我的例子我只能改成这样了,如何让已加到GUICtrlCreateList的数据不再重复添加,和判断没有选择时在GUICtrlCreateList删除相应项?