newuser 发表于 2010-11-9 16:30:18

[已解决]如何让以下代码中listview的内容全部显示而不是1个1个显示?

本帖最后由 newuser 于 2010-11-9 16:32 编辑

马虎!_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView1));设置$ListView之前,先清除它里面的所有项

这是学习的一段代码,我想一次性显示某个文件夹下的所有AVI文件的相关信息.#include<Array.au3>
#include <file.au3>
#include <GuiListView.au3>
Dim $Target="F:\家庭录象\";要查看的媒体文件所在目录
Dim $FileList,$i,$Number=1
Dim $ListView1

$Form1_1 = GUICreate("显示同一文件夹下多个AVI的媒体信息", 787, 401, 210, 154)
$ListView1 = GUICtrlCreateListView("序号 |文件格式    |视频格式    |音频格式    |音频编码    |视频编码    |总码率    "&_
                                 "|视频码率    |音频码率    |视频分辨率    |视频分辨率    ", 0, 32, 785, 241)
GUISetState(@SW_SHOW, $Form1_1)

$FileList=_FileListToArray($Target,'*.avi',1)
If IsArray($FileList)=0 Then
        MsgBox(0,'','目标文件夹里没有文件')
        Exit
Else
    For $i=1 To $FileListStep 1
          $sRL=_GetInfoArray($Target&$Filelist[$i])
                _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView1));设置$ListView之前,先清除它里面的所有项
                GUICtrlCreateListViewItem($Number&"|" & $sRL&"|"&$sRL&"|"&$sRL&"|"&$sRL&"|"&$sRL&"|"&$sRL&"|"&$sRL&"|"&$sRL&"|"&$sRL&"|"&$sRL,$ListView1)
                $Number +=1
                Sleep(5000)
                ;MsgBox(0,'',$sRL&"|"&$sRL&"|"&$sRL&"|"&$sRL&"|"&$sRL&"|"&$sRL&"|"&$sRL&"|"&$sRL&"|"&$sRL&"|"&$sRL)
      ;_ArrayDisplay($sRL)
                ;MsgBox(0,'',$FileList[$i])
    Next
EndIf

While 1
        Sleep(100)
WEnd

Func _GetInfoArray($sMediaFile)
Local $sRL
$sDLL = DllOpen("MediaInfo.dll")
$sHandle = DllCall($sDLL, "ptr", "MediaInfo_New")
$Open_Result = DllCall($sDLL, "int", "MediaInfo_Open", "ptr", $sHandle, "wstr", $sMediaFile)
;获取文件格式
DllCall($sDLL, "wstr", "MediaInfo_Option", "ptr", 0, "wstr", "Inform", "wstr", "General;%Format/String%")
$Inform = DllCall($sDLL, "wstr", "MediaInfo_Inform", "ptr", $sHandle, "int", 0)
$sRL = $Inform
;获取视频格式
DllCall($sDLL, "wstr", "MediaInfo_Option", "ptr", 0, "wstr", "Inform", "wstr", "General;%Video_Format_List%")
$Inform = DllCall($sDLL, "wstr", "MediaInfo_Inform", "ptr", $sHandle, "int", 0)
_ArrayAdd($sRL, $Inform)
;获取音频格式
DllCall($sDLL, "wstr", "MediaInfo_Option", "ptr", 0, "wstr", "Inform", "wstr", "General;%Audio_Format_List%")
$Inform = DllCall($sDLL, "wstr", "MediaInfo_Inform", "ptr", $sHandle, "int", 0)
_ArrayAdd($sRL, $Inform)
;获取音频编码
DllCall($sDLL, "wstr", "MediaInfo_Option", "ptr", 0, "wstr", "Inform", "wstr", "General;%Audio_Codec_List%")
$Inform = DllCall($sDLL, "wstr", "MediaInfo_Inform", "ptr", $sHandle, "int", 0)
_ArrayAdd($sRL, $Inform)
;获取视频编码
DllCall($sDLL, "wstr", "MediaInfo_Option", "ptr", 0, "wstr", "Inform", "wstr", "General;%Video_Codec_List%")
$Inform = DllCall($sDLL, "wstr", "MediaInfo_Inform", "ptr", $sHandle, "int", 0)
_ArrayAdd($sRL, $Inform)
;获取总码率
DllCall($sDLL, "wstr", "MediaInfo_Option", "ptr", 0, "wstr", "Inform", "wstr", "General;%BitRate/String%")
$Inform = DllCall($sDLL, "wstr", "MediaInfo_Inform", "ptr", $sHandle, "int", 0)
_ArrayAdd($sRL, $Inform)
;获取视频码率
DllCall($sDLL, "wstr", "MediaInfo_Option", "ptr", 0, "wstr", "Inform", "wstr", "Video;%BitRate/String%")
$Inform = DllCall($sDLL, "wstr", "MediaInfo_Inform", "ptr", $sHandle, "int", 0)
_ArrayAdd($sRL, $Inform)
;获取音频码率
DllCall($sDLL, "wstr", "MediaInfo_Option", "ptr", 0, "wstr", "Inform", "wstr", "Audio;%BitRate/String%")
$Inform = DllCall($sDLL, "wstr", "MediaInfo_Inform", "ptr", $sHandle, "int", 0)
_ArrayAdd($sRL, $Inform)
;获取视频分辨率
DllCall($sDLL, "wstr", "MediaInfo_Option", "ptr", 0, "wstr", "Inform", "wstr", "Video;%Width%")
$Inform = DllCall($sDLL, "wstr", "MediaInfo_Inform", "ptr", $sHandle, "int", 0)
$sWidth = $Inform
DllCall($sDLL, "wstr", "MediaInfo_Option", "ptr", 0, "wstr", "Inform", "wstr", "Video;%Height%")
$Inform = DllCall($sDLL, "wstr", "MediaInfo_Inform", "ptr", $sHandle, "int", 0)
$sHigh = $Inform
If $sHigh <> '' And $sWidth <> '' Then
_ArrayAdd($sRL, $sWidth & ' X ' & $sHigh)
Else
_ArrayAdd($sRL, '')
EndIf
;获取视频刷新率
DllCall($sDLL, "wstr", "MediaInfo_Option", "ptr", 0, "wstr", "Inform", "wstr", "Video;%FrameRate/String%")
$Inform = DllCall($sDLL, "wstr", "MediaInfo_Inform", "ptr", $sHandle, "int", 0)
_ArrayAdd($sRL, $Inform)

;删除Handle和DLL
$sHandle = DllCall($sDLL, "none", "MediaInfoList_Delete", "ptr", $sHandle)
DllClose($sDLL)
Return $sRL
EndFunc ;==>_GetInfoArray
页: [1]
查看完整版本: [已解决]如何让以下代码中listview的内容全部显示而不是1个1个显示?