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

ImageList_Draw

関数
イメージリスト内の画像を指定位置に描画する。
DLLCOMCTL32.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

BOOL ImageList_Draw(
    HIMAGELIST himl,
    INT i,
    HDC hdcDst,
    INT x,
    INT y,
    IMAGE_LIST_DRAW_STYLE fStyle
);

パラメーター

名前方向
himlHIMAGELISTin
iINTin
hdcDstHDCin
xINTin
yINTin
fStyleIMAGE_LIST_DRAW_STYLEin

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL ImageList_Draw(
    HIMAGELIST himl,
    INT i,
    HDC hdcDst,
    INT x,
    INT y,
    IMAGE_LIST_DRAW_STYLE fStyle
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("COMCTL32.dll", ExactSpelling = true)]
static extern bool ImageList_Draw(
    IntPtr himl,   // HIMAGELIST
    int i,   // INT
    IntPtr hdcDst,   // HDC
    int x,   // INT
    int y,   // INT
    uint fStyle   // IMAGE_LIST_DRAW_STYLE
);
<DllImport("COMCTL32.dll", ExactSpelling:=True)>
Public Shared Function ImageList_Draw(
    himl As IntPtr,   ' HIMAGELIST
    i As Integer,   ' INT
    hdcDst As IntPtr,   ' HDC
    x As Integer,   ' INT
    y As Integer,   ' INT
    fStyle As UInteger   ' IMAGE_LIST_DRAW_STYLE
) As Boolean
End Function
' himl : HIMAGELIST
' i : INT
' hdcDst : HDC
' x : INT
' y : INT
' fStyle : IMAGE_LIST_DRAW_STYLE
Declare PtrSafe Function ImageList_Draw Lib "comctl32" ( _
    ByVal himl As LongPtr, _
    ByVal i As Long, _
    ByVal hdcDst As LongPtr, _
    ByVal x As Long, _
    ByVal y As Long, _
    ByVal fStyle As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ImageList_Draw = ctypes.windll.comctl32.ImageList_Draw
ImageList_Draw.restype = wintypes.BOOL
ImageList_Draw.argtypes = [
    ctypes.c_ssize_t,  # himl : HIMAGELIST
    ctypes.c_int,  # i : INT
    wintypes.HANDLE,  # hdcDst : HDC
    ctypes.c_int,  # x : INT
    ctypes.c_int,  # y : INT
    wintypes.DWORD,  # fStyle : IMAGE_LIST_DRAW_STYLE
]
require 'fiddle'
require 'fiddle/import'

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

var (
	comctl32 = windows.NewLazySystemDLL("COMCTL32.dll")
	procImageList_Draw = comctl32.NewProc("ImageList_Draw")
)

// himl (HIMAGELIST), i (INT), hdcDst (HDC), x (INT), y (INT), fStyle (IMAGE_LIST_DRAW_STYLE)
r1, _, err := procImageList_Draw.Call(
	uintptr(himl),
	uintptr(i),
	uintptr(hdcDst),
	uintptr(x),
	uintptr(y),
	uintptr(fStyle),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function ImageList_Draw(
  himl: NativeInt;   // HIMAGELIST
  i: Integer;   // INT
  hdcDst: THandle;   // HDC
  x: Integer;   // INT
  y: Integer;   // INT
  fStyle: DWORD   // IMAGE_LIST_DRAW_STYLE
): BOOL; stdcall;
  external 'COMCTL32.dll' name 'ImageList_Draw';
result := DllCall("COMCTL32\ImageList_Draw"
    , "Ptr", himl   ; HIMAGELIST
    , "Int", i   ; INT
    , "Ptr", hdcDst   ; HDC
    , "Int", x   ; INT
    , "Int", y   ; INT
    , "UInt", fStyle   ; IMAGE_LIST_DRAW_STYLE
    , "Int")   ; return: BOOL
●ImageList_Draw(himl, i, hdcDst, x, y, fStyle) = DLL("COMCTL32.dll", "bool ImageList_Draw(int, int, void*, int, int, dword)")
# 呼び出し: ImageList_Draw(himl, i, hdcDst, x, y, fStyle)
# himl : HIMAGELIST -> "int"
# i : INT -> "int"
# hdcDst : HDC -> "void*"
# x : INT -> "int"
# y : INT -> "int"
# fStyle : IMAGE_LIST_DRAW_STYLE -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。