whitebear150980
Newbie | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору Уткнулся в проблему и уже неделю не могу своим чайниковым мозгом ее решить. Так вот, есть дерево GUICtrlTree, надо чтобы при левом нажатии возвращало имя строки дерева. Сейчас дерево создано через чайлды. Код: #AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #Include <File.au3> #Include <Array.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <TreeViewConstants.au3> #include <StaticConstants.au3> #include <GuiTreeView.au3> #include <GuiImageList.au3> Opt('MustDeclareVars', 0) $Debug_TV = False Example() Func Example() Local $msg, $item, $hItem, $text Local $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES, $TVS_TRACKSELECT) $cfg = 'D:\Magazin\system\system.ini' $pathall = IniRead($cfg, 'system', 'all', '') $pathdemand = $pathall & IniRead($cfg, 'system', 'demand', '') $pathBD = $pathall & IniRead($cfg, 'system', 'BD', '') $tmp_tree_tree=@TempDir&'\Tree_tmp.ini' FileDelete($tmp_tree_tree) GUICreate("My GUI", 1000, 500, 150, 200) $but = GUICtrlCreateButton('', 5, 210, 100, 20) $treeview = GUICtrlCreateTreeView(5, 5, 200, 200, $iStyle, $WS_EX_CLIENTEDGE) GUISetState() $hImage = _GUIImageList_Create(16, 16, 5, 3) _GUIImageList_AddIcon($hImage, "C:\WINDOWS\system32\shell32.dll", 110) _GUIImageList_AddIcon($hImage, "C:\WINDOWS\system32\shell32.dll", 131) _GUIImageList_AddIcon($hImage, "C:\WINDOWS\system32\shell32.dll", 165) _GUIImageList_AddIcon($hImage, "C:\WINDOWS\system32\shell32.dll", 168) _GUIImageList_AddIcon($hImage, "C:\WINDOWS\system32\shell32.dll", 137) _GUIImageList_AddIcon($hImage, "C:\WINDOWS\system32\shell32.dll", 146) _GUICtrlTreeView_SetNormalImageList($treeview, $hImage) _GUICtrlTreeView_BeginUpdate($treeview) $YearList =_FileListToArray($pathdemand); D:\Magazin\ & demand\ список папок For $y=1 To $YearList[0] $iImage = Random(0, 5, 1) $Yearitem = _GUICtrlTreeView_Add($treeview, 0, StringFormat('[%02d]' & $YearList[$y], $y), $iImage, $iImage) $MonthList = _FileListToArray($pathdemand & $YearList[$y] & '\') ; D:\Magazin\ & demand\ & 2009\ получим [05,06] If @error Then ExitLoop Else For $m=1 To $MonthList[0] $Montitem = _GUICtrlTreeView_AddChild($treeview, $Yearitem, StringFormat('[%02d]' & $MonthList[$m], $m), $iImage, $iImage) $DayList = _FileListToArray($pathdemand & $YearList[$y] & '\' & $MonthList[$m] & '\') ; D:\Magazin\ & demand\ & 2009\ & 06\ получим [01] If @error Then ExitLoop Else For $d=1 To $DayList[0] $dayitem = _GUICtrlTreeView_AddChild($treeview, $Montitem, StringFormat('[%02d]' & $DayList[$d], $d), $iImage, $iImage) $FileList = _FileListToArray($pathdemand & $YearList[$y] & '\' & $MonthList[$m] & '\' & $DayList[$d] & '\') If @error Then ExitLoop Else For $f=1 To $FileList[0] $file_name = StringSplit($FileList[$f],'.') $stat = IniRead($pathBD & $YearList[$y] & '\' & $MonthList[$m] & '\' & $DayList[$d] & '\' & $file_name[1] & '.ini', 'status', 'status', '4') $fileitem = _GUICtrlTreeView_AddChild($treeview, $dayitem, StringFormat('[%02d]' & $FileList[$f], $f), $iImage, $iImage) ;If $stat = 1 Then GUICtrlSetColor(-1, 0xff0000) ; red ;If $stat = 2 Then GUICtrlSetColor(-1, 0x0000C0) ; blue ;If $stat = 3 Then GUICtrlSetColor(-1, 0x00ff00) ; green Next EndIf Next EndIf Next EndIf Next _GUICtrlTreeView_EndUpdate($treeview) $cursor = MouseGetCursor() GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd GUIDelete() EndFunc ;==>Example | Добавлено: а если не через чайлды, все равно откликается только последний созданый Код: #Include <File.au3> #Include <Array.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <TreeViewConstants.au3> #include <StaticConstants.au3> #include <GuiTreeView.au3> #include <GuiImageList.au3> #Region ### START Koda GUI section ### Form= Local $array[10] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] Local $array1[12] = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20] $Form1 = GUICreate("Form1", 629, 453, 193, 115, -1) $TreeView1 = GUICtrlCreateTreeView(8, 8, 177, 313) For $i = 0 To $array[0] $TreeView1_0 = GUICtrlCreateTreeViewItem($array[$i], $TreeView1) For $e = 0 To $array1[0] $TreeView1_1 = GUICtrlCreateTreeViewItem($array1[$e], $TreeView1_0) Next Next $Progress1 = GUICtrlCreateProgress(0, 440, 625, 9) GUISetState() #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $TreeView1_0 MsgBox(0,'',GUICtrlRead($TreeView1_0,1)) Case $TreeView1_1 MsgBox(0,'',GUICtrlRead($TreeView1_1,1)) EndSwitch WEnd |
|