回复 11# lhylm
OK 了 幫你弄好了 但是 你的問題有兩個
1. 如何確定 你要的圖示內容 我用你的 方式 我一直抓不到 圖示
2. 所以我改抓 其他的圖示 .....
3. 重點是 每一行的圖示都不一樣..........
範例如下: PS 因為我用你的程式改的 我是用繁體系統 所以中文是亂碼 不過你自己的程式 你應該可以看得懂
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
#Include <File.au3>
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
Local $tText = DllStructCreate("wchar Text[4096]");膘跺賦凳ㄛ蚚懂溫listview蹈杅擂
Local $GUI, $hImage,$tData1,$tData2,$iITEM_COUNT=0
Local $asPathSplit[5]
$hGUI = GUICreate("ListView剞攜蹈桶 樓婥杅擂", 760, 400)
$hListView = GUICtrlCreateListView("Item1|nSubItem1|nSubItem2", 2, 2, 760, 294, $LVS_SHOWSELALWAYS + $LVS_OWNERDATA, $LVS_EX_GRIDLINES + $LVS_EX_FULLROWSELECT + $LVS_EX_DOUBLEBUFFER)
;扢离蹈遵
GUICtrlSendMsg($hListView, $LVM_SETCOLUMNWIDTH, 0, 240)
GUICtrlSendMsg($hListView, $LVM_SETCOLUMNWIDTH, 1, 240)
GUICtrlSendMsg($hListView, $LVM_SETCOLUMNWIDTH, 2, 240)
;斐膘甜壽薊芞砉蹈桶
;===================================================================
$Button1 = GUICtrlCreateButton("杅擂1", 200, 352, 73, 33)
$Button2 = GUICtrlCreateButton("杅擂2", 300, 352, 73, 33)
$Button3 = GUICtrlCreateButton("壺 ", 400, 352, 73, 33)
ok()
GUICtrlSendMsg($hListView, $LVM_SETITEMCOUNT, $iITEM_COUNT, 0)
;===================================================================
_FileIco()
GUISetState()
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $Button1
Global $aData = $tData1
GUICtrlSendMsg($hListView, $LVM_ENSUREVISIBLE, 1, 0)
GUICtrlSendMsg($hListView, $LVM_REDRAWITEMS, 0, 20)
Case $Button2
Global $aData = $tData2
GUICtrlSendMsg($hListView, $LVM_ENSUREVISIBLE, 1, 0)
GUICtrlSendMsg($hListView, $LVM_REDRAWITEMS, 0, 20)
; Case $Button_n
; Global $aData = 斕植杅擂踱枑腔媼峎杅郪,筍猁蛁砩峎僅狟梓猁湮衾麼脹衾ColumnCount睿itemCount
; 瘁寀剒猁 GUICtrlSendMsg($hListView, $LVM_SETITEMCOUNT, UBound($aData), 0)睿 AddColumn
; GUICtrlSendMsg($hListView, $LVM_ENSUREVISIBLE, 1, 0)
; GUICtrlSendMsg($hListView, $LVM_REDRAWITEMS, 0, 20)
Case $Button3
Global $aData = 0
GUICtrlSendMsg($hListView, $LVM_ENSUREVISIBLE, 1, 0)
GUICtrlSendMsg($hListView, $LVM_REDRAWITEMS, 0, 20)
EndSwitch
WEnd
GUIDelete()
Exit
Func WM_NOTIFY1($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $tNMHDR, $iIDFrom, $iCode, $tInfo, $iItem, $iSubItem
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
;$Event = DllStructGetData($tagNMHDR, 3)
Switch $iIDFrom
Case $hListView
Switch $iCode
Case $LVN_GETDISPINFOA, $LVN_GETDISPINFOW ;$LVN_GETDISPINFOA = -150, $LVN_GETDISPINFOW = -177
If IsArray($aData) Then
$tInfo = DllStructCreate($tagNMLVDISPINFO, $ilParam)
$iItem = DllStructGetData($tInfo, "Item")
$iSubItem = DllStructGetData($tInfo, "SubItem")
If $iSubItem = 0 Then DllStructSetData($tInfo, "Image", $iItem ) ;這邊有變動 必須要變動
DllStructSetData($tText, "Text", $aData[$iItem][$iSubItem]);
DllStructSetData($tInfo, "Text", DllStructGetPtr($tText));
EndIf
Case $NM_DBLCLK;邧僻
;MsgBox(0,'',"邧僻")
Case $NM_RCLICK ; 衵僻
;MsgBox(0,'',"衵僻")
EndSwitch
EndSwitch
EndFunc ;==>WM_NOTIFY
Func WM_NOTIFY($hWndGUI, $MsgID, $WParam, $LParam)
Local $tagNMHDR, $Event, $hWndFrom, $IDFrom,$tInfo, $iItem, $iSubItem
Local $tagNMHDR = DllStructCreate("int;int;int", $LParam)
If @error Then Return $GUI_RUNDEFMSG
$IDFrom = DllStructGetData($tagNMHDR, 2)
$Event = DllStructGetData($tagNMHDR, 3)
$tagNMHDR = 0
Switch $IDFrom;恁寁莉汜岈璃腔諷璃
Case $hListView
Switch $Event; 恁寁莉汜腔岈璃
Case $LVN_GETDISPINFOA, $LVN_GETDISPINFOW
If IsArray($aData) Then
$tInfo = DllStructCreate($tagNMLVDISPINFO, $LParam)
$iItem = DllStructGetData($tInfo, "Item")
$iSubItem = DllStructGetData($tInfo, "SubItem")
If $iSubItem = 0 Then DllStructSetData($tInfo, "Image", $iItem) ;這邊有變動 必須要變動
DllStructSetData($tText, "Text", $aData[$iItem][$iSubItem]);
DllStructSetData($tInfo, "Text", DllStructGetPtr($tText));
EndIf
Case $NM_CLICK ; 酘僻
;~ ...
Case $NM_DBLCLK ; 邧僻
;MsgBox(0,'',"邧僻")
Case $NM_RCLICK ; 衵僻
;MsgBox(0,'',"邧僻")
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Func ok()
$openMftFile = FileOpen("file.txt", 0)
$mftRead = FileRead($openMftFile)
Global $aRecords = StringRegExp($mftRead,"(?m)(?i).*haozip[^\\]*\v?$",3)
$iITEM_COUNT = UBound($aRecords)
Global $tData1[$iITEM_COUNT][3], $tData2[$iITEM_COUNT][3], $aData
For $i = 0 To UBound($aRecords)-1
$asPathSplit = _PathSplit($aRecords[$i], $asPathSplit[1], $asPathSplit[2], $asPathSplit[3], $asPathSplit[4])
For $j = 0 To 2
Switch $j
Case 0
$tData1[$i][0] = $asPathSplit[3]
Case 1
$tData1[$i][1] = $asPathSplit[1]&$asPathSplit[2]&$asPathSplit[3]
Case 2
$tData1[$i][2] =$asPathSplit[4]
EndSwitch
;$tData2[$i][$j] = ' 杅擂 2 $aData [' & $i & '][' & $j & ']'
Next
Next
EndFunc
Func _FileIco()
$hImage = _GUIImageList_Create()
_GUIImageList_SetIconSize($hImage,16,16)
For $m=0 To UBound($aRecords)-1
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", $m)
Next
_GUICtrlListView_SetImageList($hListView, $hImage,1)
EndFunc
|