函数参考


_GUIImageList_AddBitmap

添加位图到图像列表

#Include <GuiImageList.au3>
_GUIImageList_AddBitmap($hWnd, $sImage[, $sMask=""])

参数

$hWnd 控件句柄
$sImage 包含位图图像的路径
$sMask [可选参数] 包含位图蒙板的路径

返回值

成功: 返回图像的索引
失败: 返回 -1

注意/说明

None.

相关

_GUIImageList_Add, _GUIImageList_AddIcon

示例/演示


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

_Main()

Func _Main()
    Local $listview, $hImage
    Local $Wow64 = ""
    If @AutoItX64 Then $Wow64 = "\Wow6432Node"
    Local $sPath = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $Wow64 & "\AutoIt v3\AutoIt", "InstallDir") & "\Examples\GUI\Advanced\Images"

    GUICreate("ImageList AddBitmap", 400, 300)
    $listview = GUICtrlCreateListView("", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
    _GUICtrlListView_SetExtendedListViewStyle($listview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER))
    GUISetState()

    ; 加载图像
    $hImage = _GUIImageList_Create(16, 32)
    _GUIImageList_AddBitmap($hImage, $sPath & "\Red.bmp")
    _GUIImageList_AddBitmap($hImage, $sPath & "\Green.bmp")
    _GUIImageList_AddBitmap($hImage, $sPath & "\Blue.bmp")
    _GUICtrlListView_SetImageList($listview, $hImage, 1)

    ; 添加列
    _GUICtrlListView_AddColumn($listview, "Items", 120)

    ; 添加项目
    _GUICtrlListView_AddItem($listview, "Item 1", 0)
    _GUICtrlListView_AddItem($listview, "Item 2", 1)
    _GUICtrlListView_AddItem($listview, "Item 3", 2)

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