找回密码
 加入
搜索
查看: 3330|回复: 3

[GUI管理] (已解决)(Help!)递归出口该如何编写?

[复制链接]
发表于 2010-12-21 00:04:48 | 显示全部楼层 |阅读模式
本帖最后由 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
想实现图片中红色部分

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
 楼主| 发表于 2010-12-21 11:33:57 | 显示全部楼层
#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[0]
                        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
 楼主| 发表于 2010-12-27 10:30:10 | 显示全部楼层
顶起来 求助
 楼主| 发表于 2010-12-28 16:48:59 | 显示全部楼层
#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金钱 +10 收起 理由
pusofalse + 10

查看全部评分

您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-10 17:05 , Processed in 0.078372 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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