Win32 API 日本語リファレンス
ホームUI.Controls › ImageList_Add

ImageList_Add

関数
ビットマップとマスクをイメージリストに追加する。
DLLCOMCTL32.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

// COMCTL32.dll
#include <windows.h>

INT ImageList_Add(
    HIMAGELIST himl,
    HBITMAP hbmImage,
    HBITMAP hbmMask   // optional
);

パラメーター

名前方向
himlHIMAGELISTin
hbmImageHBITMAPin
hbmMaskHBITMAPinoptional

戻り値の型: INT

各言語での呼び出し定義

// COMCTL32.dll
#include <windows.h>

INT ImageList_Add(
    HIMAGELIST himl,
    HBITMAP hbmImage,
    HBITMAP hbmMask   // optional
);
[DllImport("COMCTL32.dll", ExactSpelling = true)]
static extern int ImageList_Add(
    IntPtr himl,   // HIMAGELIST
    IntPtr hbmImage,   // HBITMAP
    IntPtr hbmMask   // HBITMAP optional
);
<DllImport("COMCTL32.dll", ExactSpelling:=True)>
Public Shared Function ImageList_Add(
    himl As IntPtr,   ' HIMAGELIST
    hbmImage As IntPtr,   ' HBITMAP
    hbmMask As IntPtr   ' HBITMAP optional
) As Integer
End Function
' himl : HIMAGELIST
' hbmImage : HBITMAP
' hbmMask : HBITMAP optional
Declare PtrSafe Function ImageList_Add Lib "comctl32" ( _
    ByVal himl As LongPtr, _
    ByVal hbmImage As LongPtr, _
    ByVal hbmMask As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ImageList_Add = ctypes.windll.comctl32.ImageList_Add
ImageList_Add.restype = ctypes.c_int
ImageList_Add.argtypes = [
    ctypes.c_ssize_t,  # himl : HIMAGELIST
    wintypes.HANDLE,  # hbmImage : HBITMAP
    wintypes.HANDLE,  # hbmMask : HBITMAP optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('COMCTL32.dll')
ImageList_Add = Fiddle::Function.new(
  lib['ImageList_Add'],
  [
    Fiddle::TYPE_INTPTR_T,  # himl : HIMAGELIST
    Fiddle::TYPE_VOIDP,  # hbmImage : HBITMAP
    Fiddle::TYPE_VOIDP,  # hbmMask : HBITMAP optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "comctl32")]
extern "system" {
    fn ImageList_Add(
        himl: isize,  // HIMAGELIST
        hbmImage: *mut core::ffi::c_void,  // HBITMAP
        hbmMask: *mut core::ffi::c_void  // HBITMAP optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("COMCTL32.dll")]
public static extern int ImageList_Add(IntPtr himl, IntPtr hbmImage, IntPtr hbmMask);
"@
$api = Add-Type -MemberDefinition $sig -Name 'COMCTL32_ImageList_Add' -Namespace Win32 -PassThru
# $api::ImageList_Add(himl, hbmImage, hbmMask)
#uselib "COMCTL32.dll"
#func global ImageList_Add "ImageList_Add" sptr, sptr, sptr
; ImageList_Add himl, hbmImage, hbmMask   ; 戻り値は stat
; himl : HIMAGELIST -> "sptr"
; hbmImage : HBITMAP -> "sptr"
; hbmMask : HBITMAP optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "COMCTL32.dll"
#cfunc global ImageList_Add "ImageList_Add" sptr, sptr, sptr
; res = ImageList_Add(himl, hbmImage, hbmMask)
; himl : HIMAGELIST -> "sptr"
; hbmImage : HBITMAP -> "sptr"
; hbmMask : HBITMAP optional -> "sptr"
; INT ImageList_Add(HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask)
#uselib "COMCTL32.dll"
#cfunc global ImageList_Add "ImageList_Add" intptr, intptr, intptr
; res = ImageList_Add(himl, hbmImage, hbmMask)
; himl : HIMAGELIST -> "intptr"
; hbmImage : HBITMAP -> "intptr"
; hbmMask : HBITMAP optional -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	comctl32 = windows.NewLazySystemDLL("COMCTL32.dll")
	procImageList_Add = comctl32.NewProc("ImageList_Add")
)

// himl (HIMAGELIST), hbmImage (HBITMAP), hbmMask (HBITMAP optional)
r1, _, err := procImageList_Add.Call(
	uintptr(himl),
	uintptr(hbmImage),
	uintptr(hbmMask),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function ImageList_Add(
  himl: NativeInt;   // HIMAGELIST
  hbmImage: THandle;   // HBITMAP
  hbmMask: THandle   // HBITMAP optional
): Integer; stdcall;
  external 'COMCTL32.dll' name 'ImageList_Add';
result := DllCall("COMCTL32\ImageList_Add"
    , "Ptr", himl   ; HIMAGELIST
    , "Ptr", hbmImage   ; HBITMAP
    , "Ptr", hbmMask   ; HBITMAP optional
    , "Int")   ; return: INT
●ImageList_Add(himl, hbmImage, hbmMask) = DLL("COMCTL32.dll", "int ImageList_Add(int, void*, void*)")
# 呼び出し: ImageList_Add(himl, hbmImage, hbmMask)
# himl : HIMAGELIST -> "int"
# hbmImage : HBITMAP -> "void*"
# hbmMask : HBITMAP optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。