函数参考


_GUIImageList_Remove

删除图片列表中的图像

#Include <GuiImageList.au3>
_GUIImageList_Remove($hWnd[, $iIndex = -1])

参数

$hWnd 控件句柄
$iIndex [可选参数] 被删除图像的索引. 如为 -1,函数删除所有图像

返回值

成功: 返回 True
失败: 返回 False

注意/说明

 当一个图像被删除,其余各图像的索引将进行调整,
 使图像索引总是从零到图像列表中图像数目少1.
 例如,删除索引为 0 的图像,则图像 1 的索引为 0,图像 2 的索引为 1,依此类推.

相关

示例/演示


#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>

_Main()

Func _Main()
    Local $listview, $hImage
    Local $exStyles = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)

    GUICreate("ImageList Remove", 400, 300)
    $listview = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    _GUICtrlListView_SetExtendedListViewStyle($listview, $exStyles)
    GUISetState()

    ; 加载图像
    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 110)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 131)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
    _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)

    ; 添加列
    _GUICtrlListView_AddColumn($listview, "Column 1", 120)
    _GUICtrlListView_AddColumn($listview, "Column 2", 100)
    _GUICtrlListView_AddColumn($listview, "Column 3", 100)

    ; 添加项目
    _GUICtrlListView_AddItem($listview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($listview, 0, "Row 1: Col 2", 1, 1)
    _GUICtrlListView_AddSubItem($listview, 0, "Row 1: Col 3", 2, 2)
    _GUICtrlListView_AddItem($listview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($listview, 1, "Row 2: Col 2", 1, 2)
    _GUICtrlListView_AddItem($listview, "Row 3: Col 1", 2)
    _GUICtrlListView_AddItem($listview, "Row 4: Col 1", 3)
    _GUICtrlListView_AddItem($listview, "Row 5: Col 1", 4)
    _GUICtrlListView_AddSubItem($listview, 4, "Row 5: Col 2", 1, 3)
    _GUICtrlListView_AddItem($listview, "Row 6: Col 1", 5)
    _GUICtrlListView_AddSubItem($listview, 5, "Row 6: Col 2", 1, 4)
    _GUICtrlListView_AddSubItem($listview, 5, "Row 6: Col 3", 2, 3)

    MsgBox(4096, "信息", "Removing Image Index 0")
    _GUIImageList_Remove($hImage, 0)

    _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($listview))

    ; 添加项目
    _GUICtrlListView_AddItem($listview, "Row 1: Col 1", 0)
    _GUICtrlListView_AddSubItem($listview, 0, "Row 1: Col 2", 1, 1)
    _GUICtrlListView_AddSubItem($listview, 0, "Row 1: Col 3", 2, 2)
    _GUICtrlListView_AddItem($listview, "Row 2: Col 1", 1)
    _GUICtrlListView_AddSubItem($listview, 1, "Row 2: Col 2", 1, 2)
    _GUICtrlListView_AddItem($listview, "Row 3: Col 1", 2)
    _GUICtrlListView_AddItem($listview, "Row 4: Col 1", 3)
    _GUICtrlListView_AddItem($listview, "Row 5: Col 1", 4)
    _GUICtrlListView_AddSubItem($listview, 4, "Row 5: Col 2", 1, 3)
    _GUICtrlListView_AddItem($listview, "Row 6: Col 1", 5)
    _GUICtrlListView_AddSubItem($listview, 5, "Row 6: Col 2", 1, 4)
    _GUICtrlListView_AddSubItem($listview, 5, "Row 6: Col 3", 2, 3)

    ; 循环直到用户退出
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>_Main