#include <file.au3>
#include <GuiListView.au3>
$form = GUICreate("test", 220, 250, 100, 200)
Local $msg
$image_file_listview = GUICtrlCreateListView("image file", 10, 10, 200, 150)
$list = GUICtrlGetHandle(-1)
$bt = GUICtrlCreateButton('选择文件夹', 70, 200, 85, 28)
GUISetState(@SW_SHOW)
While 1
$msg = GUIGetMsg()
Switch $msg
Case -3
Exit
Case $bt
_set_image_list()
EndSwitch
WEnd
Func _set_image_list()
Local $folder = FileSelectFolder('请选择一个目录', '', 1 + 2 + 4, @ScriptDir, $form)
If @error Then Return
_GUICtrlListView_DeleteAllItems($list)
Local $jpg_file_array = _FileListToArray($folder, "*.jpg", 1)
If IsArray($jpg_file_array) Then
_GUICtrlListView_BeginUpdate($list)
For $i = 1 To $jpg_file_array[0]
_GUICtrlListView_AddItem($list, $jpg_file_array[$i])
Next
_GUICtrlListView_EndUpdate($list)
EndIf
EndFunc
|