(已解决)(Help!)递归出口该如何编写?
本帖最后由 yarsye 于 2010-12-28 16:49 编辑求高手帮忙 这个递归的口应该怎么样写?
已解决:见4楼#include <GuiConstantsEx.au3>
#include <GuiTreeView.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <file.au3>
#include <array.au3>
$GUI = GUICreate("(UDF Created) TreeView Create", 400, 640)
$hTreeView = _GUICtrlTreeView_Create($GUI, 2, 2, 396, 568);,$iStyle, $WS_EX_CLIENTEDGE)
_GUICtrlTreeView_BeginUpdate($hTreeView)
Recursion(@ProgramFilesDir)
_GUICtrlTreeView_EndUpdate($hTreeView)
GUISetState()
Do
Until GUIGetMsg() = -3
Func Recursion($current)
$item = _GUICtrlTreeView_Add($hTreeView,0,$current)
Local $search = FileFindFirstFile($current & "\*.*")
While 1
Dim $file = FileFindNextFile($search)
If @error Or StringLen($file) < 1 Then ExitLoop
If StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then
$item1 = _GUICtrlTreeView_AddChild($hTreeView,$item,$current & '\' & $file)
;~ Recursion($current & "\" & $file)
else
$item2 = _GUICtrlTreeView_AddChild($hTreeView,$item,$current & '\' & $file)
EndIf
WEnd
Return
EndFunc ;==>Search
想实现图片中红色部分 #include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <File.au3>
#Include <Array.au3>
#Region ### START Koda GUI section ### Form=d:\4 study\autoit\code\ctl file copying utility\form2.kxf
$Gui = GUICreate("Server File Copying Utility", 619, 590, 249, 122)
GUISetBkColor(0x99B4D1)
$ListBox1 = GUICtrlCreateListView("Name|Size", 0, 144, 289, 240)
list(@AppDataCommonDir)
$Button1 = GUICtrlCreateButton(">", 4, 87, 30, 25)
$Button2 = GUICtrlCreateButton(">>", 260, 88, 31, 25)
$Button3 = GUICtrlCreateButton("<", 565, 89, 31, 25)
$Button4 = GUICtrlCreateButton("<<", 317, 90, 32, 25)
$ListBox2 = GUICtrlCreateList("", 312, 144, 289, 240)
GUICtrlSetData(-1, "")
$Input1 = GUICtrlCreateInput("Input1", 56, 48, 233, 21)
$Input2 = GUICtrlCreateInput("Input1", 376, 48, 225, 21)
$Label1 = GUICtrlCreateLabel("System1", 8, 8, 67, 17)
$Label2 = GUICtrlCreateLabel("System2", 320, 8, 43, 17)
$Label3 = GUICtrlCreateLabel("Location", 8, 48, 45, 17)
$Label4 = GUICtrlCreateLabel("Location", 320, 48, 45, 17)
$Edit1 = GUICtrlCreateEdit("", 0, 432, 609, 129)
GUICtrlSetData(-1, "Edit1")
$Log = GUICtrlCreateLabel("Log", 0, 408, 22, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
;~ Case $Button1
;~ $Button1FileOpenDialog = FileOpenDialog('Select the Files in your server','','所有文件(*.*)',4)
EndSwitch
WEnd
;=====================Functions below=====================
Func list($dirname)
$FileList = _FileListToArray($dirname)
If UBound($FileList) <> '' Then
For $i = 1 To $FileList
If StringInStr(FileGetAttrib($FileList[$i]), 'D') Then
GUICtrlCreateListViewItem($dirname & '\' & $FileList[$i] & '||文件夹', $ListBox1)
Else
GUICtrlCreateListViewItem($dirname & '\' & $FileList[$i] & '|' & FileGetSize($dirname & '\' & $FileList[$i]) & '|?', $ListBox1)
EndIf
Next
EndIf
Endfunc ;==>list 顶起来 求助 #include <GuiConstantsEx.au3>
#include <GuiTreeView.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <file.au3>
#include <array.au3>
$GUI = GUICreate("(UDF Created) TreeView Create", 400, 640)
$hTreeView = _GUICtrlTreeView_Create($GUI, 2, 2, 396, 568);,$iStyle, $WS_EX_CLIENTEDGE)
_GUICtrlTreeView_BeginUpdate($hTreeView)
Recursion(@ProgramFilesDir,'')
_GUICtrlTreeView_EndUpdate($hTreeView)
GUISetState()
Do
Until GUIGetMsg() = -3
Func Recursion($current,$flag)
If $flag = '' Then $item1 = _GUICtrlTreeView_Add($hTreeView,0,$current)
Local $search = FileFindFirstFile($current & "\*.*")
While 1
Dim $file = FileFindNextFile($search)
If @error Or StringLen($file) < 1 Then ExitLoop
If StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then
If $flag <> '' Then $item1 = $flag
$item2 = _GUICtrlTreeView_AddChild($hTreeView,$item1,$current & '\' & $file)
Recursion($current & "\" & $file,$item2)
Else
If $flag <> '' Then $item1 = $flag
$item3 = _GUICtrlTreeView_AddChild($hTreeView,$item1,$current & '\' & $file)
EndIf
WEnd
Return
EndFunc ;==>Search
页:
[1]