ListView控件如何添加这种箭头【已解决】
本帖最后由 sunafter 于 2014-10-5 17:05 编辑如图,扩展样式里好像没有看到 _GUICtrlListView_SetItemImage 本帖最后由 netegg 于 2014-10-5 06:24 编辑
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
Opt('MustDeclareVars', 1)
_Main()
Func _Main()
Local $listview, $hImage
Local $exStyles = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)
GUICreate("ImageList AddIcon", 400, 300)
$listview = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
_GUICtrlListView_SetExtendedListViewStyle($listview, $exStyles)
GUISetState()
; Load images
$hImage = _GUIImageList_Create(16, 16, 5, 3)
_GUIImageList_AddIcon($hImage, @SystemDir & "\mmcndmgr.dll",32)
_GUICtrlListView_SetImageList($listview, $hImage, 1)
; Add columns
_GUICtrlListView_AddColumn($listview, "",20)
_GUICtrlListView_AddColumn($listview, "Column 1", 120)
_GUICtrlListView_AddColumn($listview, "Column 2", 100)
_GUICtrlListView_AddColumn($listview, "Column 3", 100)
; Add items
_GUICtrlListView_AddItem($listview, "", 0)
_GUICtrlListView_AddSubItem($listview, 0, "Row 1: Col 1", 1)
_GUICtrlListView_AddSubItem($listview, 0, "Row 1: Col 2", 2)
_GUICtrlListView_AddSubItem($listview, 0, "Row 1: Col 3", 3)
_GUICtrlListView_AddItem($listview,"", 1)
_GUICtrlListView_AddSubItem($listview, 1, "Row 2: Col 1", 1)
_GUICtrlListView_AddSubItem($listview, 1, "Row 2: Col 2", 2)
; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>_Main 不过后续操作,你自己先想吧,我不想把所有代码都写了,大体思路是切换选项的时候,要更换图像列表索引,不过你没说明白到底是hover还是hot还是select,操作虽说大体相同,但不一样 回复 4# netegg
好的,谢谢了 做个标记,以后用的到。#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
Global $hImage,$ListView
_Main()
Func _Main()
Local $exStyles = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)
GUICreate("ImageList AddIcon", 400, 300)
$listview = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
_GUICtrlListView_SetExtendedListViewStyle($listview, $exStyles)
GUISetState()
; Load images
$hImage = _GUIImageList_Create(16, 16, 5, 3)
_GUIImageList_AddIcon($hImage, @SystemDir & "\mmcndmgr.dll",32)
;_GUIImageList_AddIcon($hImage, @SystemDir & "\imageres.dll",12)
_GUICtrlListView_SetImageList($listview, $hImage, 1)
; Add columns
_GUICtrlListView_AddColumn($listview, "",20)
_GUICtrlListView_AddColumn($listview, "Column 1", 120)
_GUICtrlListView_AddColumn($listview, "Column 2", 100)
_GUICtrlListView_AddColumn($listview, "Column 3", 100)
; Add items
_GUICtrlListView_AddItem($listview, "", 0)
_GUICtrlListView_AddSubItem($listview, 0, "Row 1: Col 1", 1)
_GUICtrlListView_AddSubItem($listview, 0, "Row 1: Col 2", 2)
_GUICtrlListView_AddSubItem($listview, 0, "Row 1: Col 3", 3)
_GUICtrlListView_AddItem($listview,"", 1)
_GUICtrlListView_AddSubItem($listview, 1, "Row 2: Col 1", 1)
_GUICtrlListView_AddSubItem($listview, 1, "Row 2: Col 2", 2)
_GUICtrlListView_AddItem($listview,"", 2)
_GUICtrlListView_AddSubItem($listview, 2, "Row 2: Col 1", 1)
_GUICtrlListView_AddSubItem($listview, 2, "Row 2: Col 2", 2)
;_GUICtrlListView_SetItemImage($listview,1,0)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
; Loop until user exits
While 1
$nMsg=GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
_GUIImageList_Destroy($hImage)
GUIDelete()
EndFunc ;==>_Main
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iCode, $tNMHDR, $hWndListView1, $SelectedID, $selectindex, $LISTVIEWcount,$selecttext,$selectarr
$hWndListView1 =WinGetHandle($ListView)
If Not IsHWnd($ListView) Then $hWndListView1 = GUICtrlGetHandle($ListView)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView1
Switch $iCode
Case $NM_DBLCLK
MsgBox(0,"","rdblclk")
Case $NM_CLICK
$selectindex= _GUICtrlListView_GetSelectionMark($listview)
$LISTVIEWcount=_GUICtrlListView_GetItemCount($ListView)
For $I=0 To $LISTVIEWcount-1
If $I=$selectindex Then
_GUICtrlListView_SetItemImage($listview,$I,0)
Else
_GUICtrlListView_SetItemImage($listview,$I,1)
EndIf
Next
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
页:
[1]