回复 7# qsy666888
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
Local $hGui, $listview, $hImage
Local $exStyles = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)
$hGui = GUICreate("ImageList: Icon hinzufugen", 400, 300)
$listview = _GUICtrlListView_Create($hGui, "", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
_GUICtrlListView_SetExtendedListViewStyle($listview, $exStyles)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUISetState()
; Ladt die Bilder
$hImage = _GUIImageList_Create(16, 16, 5, 3)
_GUIImageList_AddIcon($hImage, "C:\Users\WORKA\Pictures\0\C1.ico",0)
_GUIImageList_AddIcon($hImage, "C:\Users\WORKA\Pictures\0\C2.ico",0)
_GUIImageList_AddIcon($hImage, "C:\Users\WORKA\Pictures\0\C3.ico", 0)
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
_GUICtrlListView_SetImageList($listview, $hImage, 1)
; Fugt die Spalten hinzu
_GUICtrlListView_AddColumn($listview, "Spalte 1", 120)
_GUICtrlListView_AddColumn($listview, "Spalte 2", 120)
_GUICtrlListView_AddColumn($listview, "Spalte 3", 120)
_GUICtrlListView_AddColumn($listview, "", 16)
_GUICtrlListView_AddColumn($listview, "", 16)
_GUICtrlListView_AddColumn($listview, "", 16)
_GUICtrlListView_AddColumn($listview, "", 16)
_GUICtrlListView_AddColumn($listview, "", 16)
; Fugt die Items hinzu
_GUICtrlListView_AddItem($listview, "Zeile 1: Spalte 1", 0)
_GUICtrlListView_AddSubItem($listview, 0, "Zeile 1: Spalte 2", 1, 1)
_GUICtrlListView_AddSubItem($listview, 0, "Zeile 1: Spalte 3", 2, 2)
_GUICtrlListView_AddItem($listview, "Zeile 2: Spalte 1", 1)
_GUICtrlListView_AddSubItem($listview, 1, "Zeile 2: Spalte 2", 1, 2)
_GUICtrlListView_AddItem($listview, "Zeile 3: Spalte 1", 2)
_GUICtrlListView_AddItem($listview, "Zeile 4: Spalte 1", 3)
_GUICtrlListView_AddItem($listview, "Zeile 5: Spalte 1", 4)
_GUICtrlListView_AddSubItem($listview, 4, "Zeile 5: Spalte 2", 1, 3)
_GUICtrlListView_AddItem($listview, "Zeile 6: Spalte 1", 5)
_GUICtrlListView_AddSubItem($listview, 5, "Zeile 6: Spalte 2", 1, 4)
_GUICtrlListView_AddSubItem($listview, 5, "Zeile 6: Spalte 3", 2, 3)
_GUICtrlListView_AddSubItem($listview, 0, "", 3,0)
_GUICtrlListView_AddSubItem($listview, 0, "", 4,1)
_GUICtrlListView_AddSubItem($listview, 0, "", 5,2)
; Die Schleife wiederholt sich, bis der Benutzer die Beenden-Aktion der GUI auslost
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $tInfo
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $iCode
Case $NM_CLICK;??
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
$iIndex = DllStructGetData($tInfo, "Index")
$iSub = DllStructGetData($tInfo, "SubItem")
IF $iIndex=0 AND $iSub=3 Then
ConsoleWrite("你點了+"&@CRLF)
MsgBox(0,"","你點了+")
ElseIf $iIndex=0 AND $iSub=4 Then
MsgBox(0,"","你點了搜尋")
ElseIf $iIndex=0 AND $iSub=5 Then
MsgBox(0,"","你點了停止")
EndIf
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc
|