返回 ListView 项目状态
#include <GuiListView.au3>
_GUICtrlListView_GetItemState($hWnd, $iIndex, $iMask)
$hWnd | 控件的控件ID/句柄. |
$iIndex | 基于 0 开始计算的项目索引 |
$iMask | 状态信息. 可以是下列项的组合: $LVIS_CUT - 项目被标记为剪切/粘贴操作 $LVIS_DROPHILITED - 项目作为拖放目标高亮显示 $LVIS_FOCUSED - 项目具有焦点, 被标准焦点矩形包围. $LVIS_SELECTED - 项目被选中 $LVIS_OVERLAYMASK - 使用掩码获取项目的覆盖图像索引 $LVIS_STATEIMAGEMASK - 使用掩码获取项目的状态图像索引 |
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
$Debug_LV = False ; 检查传递给 ListView 函数的类名, 设置为True并输出到一个控件的句柄,用于检查它是否工作
_Main()
Func _Main()
Local $hImage, $hListView
GUICreate("ListView Get Item State", 400, 300)
$hListView = GUICtrlCreateListView("", 2, 2, 394, 268)
_GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
GUISetState()
; 加载图像
$hImage = _GUIImageList_Create()
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF0000, 16, 16))
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x00FF00, 16, 16))
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x0000FF, 16, 16))
_GUICtrlListView_SetImageList($hListView, $hImage, 1)
; 添加列
_GUICtrlListView_AddColumn($hListView, "Column 1", 100)
_GUICtrlListView_AddColumn($hListView, "Column 2", 100)
_GUICtrlListView_AddColumn($hListView, "Column 3", 100)
; 添加项目
_GUICtrlListView_AddItem($hListView, "Row 1: Col 1", 0)
_GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 2", 1, 1)
_GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 3", 2, 2)
_GUICtrlListView_AddItem($hListView, "Row 2: Col 1", 1)
_GUICtrlListView_AddSubItem($hListView, 1, "Row 2: Col 2", 1, 2)
_GUICtrlListView_AddItem($hListView, "Row 3: Col 1", 2)
; Get item 1 state
_GUICtrlListView_SetItemState($hListView, 0, $LVIS_FOCUSED, $LVIS_FOCUSED)
MsgBox(4160, "信息", "Item 1 State: " & _GUICtrlListView_GetItemState($hListView, 0, $LVIS_FOCUSED))
; 循环直到用户退出
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>_Main