本帖最后由 雨林GG 于 2011-7-20 15:10 编辑
对于文件大小为 0 b的文件复选框设置为不可选状态!~~
实在搞不懂包含文件中那些常量是什么意思 !!!
附源码!#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <Array.au3>
Global $aLog[1][2], $FileCount = 0
_Filelist(@WindowsDir & "\*.log", $aLog)
ReDim $aLog[$FileCount][2]
;_ArrayDisplay($aLog)
Dim $Listem[$FileCount]
$MainForm = GUICreate("Form1", 550, 450, -1, -1)
$hImage = _GUIImageList_Create(24, 24, 5, 3, 4)
$SoftListView = GUICtrlCreateListView(" 文件| 大小", 0, 21, 549, 343);, $LVS_ICON, BitOR($LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))
_GUICtrlListView_SetImageList($SoftListView, $hImage, 0)
_GUICtrlListView_SetExtendedListViewStyle($SoftListView, BitOR($LVS_EX_CHECKBOXES, $LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) ;, $LVS_EX_SIMPLESELECT
_GUICtrlListView_SetColumnWidth($SoftListView, 0, 440) ;软件名称
_GUICtrlListView_SetColumnWidth($SoftListView, 1, 100) ;
For $i = 0 To $FileCount - 1
$Listem[$i] = GUICtrlCreateListViewItem($aLog[$i][0] & "|" & $aLog[$i][1], $SoftListView)
If $aLog[$i][1] <> "0 b" Then
_GUICtrlListView_SetItemChecked($SoftListView, $i)
Else
;这里设置为不可选状态 <-----------------------------------------------
;_GUICtrlListView_SetItemState($SoftListView, $i, $LVIS_CUT, $LVIS_CUT)
EndIf
Next
GUISetState(@SW_SHOW)
Do
Until GUIGetMsg() = -3
Func _FileList($SearchLog, ByRef $Array)
; 显示当前目录中所有文件的文件名.
$search = FileFindFirstFile($SearchLog)
; 检查搜索是否成功
If $search = -1 Then Return
While 1
$file = FileFindNextFile($search)
If @error Then ExitLoop
$Array[$FileCount][0] = $file
$Array[$FileCount][1] = MylBytes(FileGetSize(@WindowsDir & "" & $file))
$FileCount += 1
ReDim $Array[$FileCount + 1][2]
WEnd
; 关闭搜索句柄
FileClose($search)
EndFunc ;==>_FileList
Func MylBytes($lBytes)
If $lBytes < 1024 Then
Return ($lBytes & " b")
ElseIf $lBytes < 1048576 Then
Return Int(($lBytes / 1024)) & " K"
ElseIf $lBytes < 536870912 Then
Return Round($lBytes / 1024 / 1024, 2) & " M"
Else
Return Round($lBytes / (1024 ^ 2) / 1024, 2) & " G"
EndIf
EndFunc ;==>MylBytes
|