#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
Opt('MustDeclareVars', 1)
$Debug_LV = False ; 检查传递给函数的类名, 设置为真并使用另一控件句柄观察其工作
Global $hListView, $edit
_Main()
Func _Main()
Local $GUI, $hHeader
$GUI = GUICreate("(UDF Created) ListView Create", 400, 540)
$edit = GUICtrlCreateEdit("", 2, 277, 394, 258, BitOR($WS_VSCROLL, $ES_AUTOVSCROLL))
$hListView = _GUICtrlListView_Create($GUI, "", 2, 2, 394, 268)
_GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
GUISetState()
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
; 加载图像
; 添加列
_GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 100)
_GUICtrlListView_InsertColumn($hListView, 1, "Column 2", 100)
_GUICtrlListView_InsertColumn($hListView, 2, "Column 3", 100)
; 添加项
_GUICtrlListView_AddItem($hListView, "Row 1: Col 1", 0)
_GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 2", 1)
_GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 3", 2)
_GUICtrlListView_AddItem($hListView, "Row 2: Col 1", 1)
_GUICtrlListView_AddSubItem($hListView, 1, "Row 2: Col 2", 1)
_GUICtrlListView_AddItem($hListView, "Row 3: Col 1", 2)
$hHeader = _GUICtrlListView_GetHeader($hListView)
_GUICtrlHeader_SetItemAlign($hHeader, 0, 0)
_GUICtrlHeader_SetItemAlign($hHeader, 1, 1)
_GUICtrlHeader_SetItemAlign($hHeader, 2, 2)
; 循环至用户退出
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>_Main