ホーム › UI.Controls › ImageList_Draw
ImageList_Draw
関数イメージリスト内の画像を指定位置に描画する。
シグネチャ
// COMCTL32.dll
#include <windows.h>
BOOL ImageList_Draw(
HIMAGELIST himl,
INT i,
HDC hdcDst,
INT x,
INT y,
IMAGE_LIST_DRAW_STYLE fStyle
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| himl | HIMAGELIST | in | イメージリストへのハンドル。 | ||||||||||||||||||||
| i | INT | in | 描画するイメージの0から始まるインデックス。 | ||||||||||||||||||||
| hdcDst | HDC | in | 描画先デバイスコンテキストへのハンドル。 | ||||||||||||||||||||
| x | INT | in | 指定したデバイスコンテキスト内で描画するx座標。 | ||||||||||||||||||||
| y | INT | in | 指定したデバイスコンテキスト内で描画するy座標。 | ||||||||||||||||||||
| fStyle | IMAGE_LIST_DRAW_STYLE | in | 描画スタイルと、オプションでオーバーレイイメージ。オーバーレイイメージのインデックスを指定する方法については、このトピックの末尾にあるコメントセクションを参照してください。このパラメーターには、オーバーレイイメージのインデックスと、次の値の1つ以上を組み合わせて指定できます。
|
戻り値の型: BOOL
公式ドキュメント
指定したデバイスコンテキストにイメージリストの項目を描画します。(ImageList_Draw)
戻り値
型: BOOL
成功した場合は0以外を返し、それ以外の場合は0を返します。
解説(Remarks)
オーバーレイイメージは、i パラメーターで指定されたプライマリイメージの上に透過的に描画されます。fStyle パラメーターでオーバーレイイメージを指定するには、INDEXTOOVERLAYMASK マクロを使用して、オーバーレイイメージの1から始まるインデックスをシフトします。OR演算子を使用して、このマクロの戻り値と fStyle パラメーターで指定された描画スタイルフラグを論理的に結合してください。あらかじめ ImageList_SetOverlayImage 関数を使用して、このイメージをオーバーレイイメージとして指定しておく必要があります。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// 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 <MarshalAs(UnmanagedType.Bool)> 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 // BOOLfunction 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)。const std = @import("std");
extern "comctl32" fn ImageList_Draw(
himl: isize, // HIMAGELIST
i: i32, // INT
hdcDst: ?*anyopaque, // HDC
x: i32, // INT
y: i32, // INT
fStyle: u32 // IMAGE_LIST_DRAW_STYLE
) callconv(std.os.windows.WINAPI) i32;proc ImageList_Draw(
himl: int, # HIMAGELIST
i: int32, # INT
hdcDst: pointer, # HDC
x: int32, # INT
y: int32, # INT
fStyle: uint32 # IMAGE_LIST_DRAW_STYLE
): int32 {.importc: "ImageList_Draw", stdcall, dynlib: "COMCTL32.dll".}pragma(lib, "comctl32");
extern(Windows)
int ImageList_Draw(
ptrdiff_t himl, // HIMAGELIST
int i, // INT
void* hdcDst, // HDC
int x, // INT
int y, // INT
uint fStyle // IMAGE_LIST_DRAW_STYLE
);ccall((:ImageList_Draw, "COMCTL32.dll"), stdcall, Int32,
(Int, Int32, Ptr{Cvoid}, Int32, Int32, UInt32),
himl, i, hdcDst, x, y, fStyle)
# himl : HIMAGELIST -> Int
# i : INT -> Int32
# hdcDst : HDC -> Ptr{Cvoid}
# x : INT -> Int32
# y : INT -> Int32
# fStyle : IMAGE_LIST_DRAW_STYLE -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t ImageList_Draw(
intptr_t himl,
int32_t i,
void* hdcDst,
int32_t x,
int32_t y,
uint32_t fStyle);
]]
local comctl32 = ffi.load("comctl32")
-- comctl32.ImageList_Draw(himl, i, hdcDst, x, y, fStyle)
-- himl : HIMAGELIST
-- i : INT
-- hdcDst : HDC
-- x : INT
-- y : INT
-- fStyle : IMAGE_LIST_DRAW_STYLE
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('COMCTL32.dll');
const ImageList_Draw = lib.func('__stdcall', 'ImageList_Draw', 'int32_t', ['intptr_t', 'int32_t', 'void *', 'int32_t', 'int32_t', 'uint32_t']);
// ImageList_Draw(himl, i, hdcDst, x, y, fStyle)
// himl : HIMAGELIST -> 'intptr_t'
// i : INT -> 'int32_t'
// hdcDst : HDC -> 'void *'
// x : INT -> 'int32_t'
// y : INT -> 'int32_t'
// fStyle : IMAGE_LIST_DRAW_STYLE -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("COMCTL32.dll", {
ImageList_Draw: { parameters: ["isize", "i32", "pointer", "i32", "i32", "u32"], result: "i32" },
});
// lib.symbols.ImageList_Draw(himl, i, hdcDst, x, y, fStyle)
// himl : HIMAGELIST -> "isize"
// i : INT -> "i32"
// hdcDst : HDC -> "pointer"
// x : INT -> "i32"
// y : INT -> "i32"
// fStyle : IMAGE_LIST_DRAW_STYLE -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t ImageList_Draw(
intptr_t himl,
int32_t i,
void* hdcDst,
int32_t x,
int32_t y,
uint32_t fStyle);
C, "COMCTL32.dll");
// $ffi->ImageList_Draw(himl, i, hdcDst, x, y, fStyle);
// himl : HIMAGELIST
// i : INT
// hdcDst : HDC
// x : INT
// y : INT
// fStyle : IMAGE_LIST_DRAW_STYLE
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Comctl32 extends StdCallLibrary {
Comctl32 INSTANCE = Native.load("comctl32", Comctl32.class);
boolean ImageList_Draw(
long himl, // HIMAGELIST
int i, // INT
Pointer hdcDst, // HDC
int x, // INT
int y, // INT
int fStyle // IMAGE_LIST_DRAW_STYLE
);
}@[Link("comctl32")]
lib LibCOMCTL32
fun ImageList_Draw = ImageList_Draw(
himl : LibC::SSizeT, # HIMAGELIST
i : Int32, # INT
hdcDst : Void*, # HDC
x : Int32, # INT
y : Int32, # INT
fStyle : UInt32 # IMAGE_LIST_DRAW_STYLE
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ImageList_DrawNative = Int32 Function(IntPtr, Int32, Pointer<Void>, Int32, Int32, Uint32);
typedef ImageList_DrawDart = int Function(int, int, Pointer<Void>, int, int, int);
final ImageList_Draw = DynamicLibrary.open('COMCTL32.dll')
.lookupFunction<ImageList_DrawNative, ImageList_DrawDart>('ImageList_Draw');
// himl : HIMAGELIST -> IntPtr
// i : INT -> Int32
// hdcDst : HDC -> Pointer<Void>
// x : INT -> Int32
// y : INT -> Int32
// fStyle : IMAGE_LIST_DRAW_STYLE -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "ImageList_Draw"
c_ImageList_Draw :: CIntPtr -> Int32 -> Ptr () -> Int32 -> Int32 -> Word32 -> IO CInt
-- himl : HIMAGELIST -> CIntPtr
-- i : INT -> Int32
-- hdcDst : HDC -> Ptr ()
-- x : INT -> Int32
-- y : INT -> Int32
-- fStyle : IMAGE_LIST_DRAW_STYLE -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let imagelist_draw =
foreign "ImageList_Draw"
(intptr_t @-> int32_t @-> (ptr void) @-> int32_t @-> int32_t @-> uint32_t @-> returning int32_t)
(* himl : HIMAGELIST -> intptr_t *)
(* i : INT -> int32_t *)
(* hdcDst : HDC -> (ptr void) *)
(* x : INT -> int32_t *)
(* y : INT -> int32_t *)
(* fStyle : IMAGE_LIST_DRAW_STYLE -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library comctl32 (t "COMCTL32.dll"))
(cffi:use-foreign-library comctl32)
(cffi:defcfun ("ImageList_Draw" image-list-draw :convention :stdcall) :int32
(himl :int64) ; HIMAGELIST
(i :int32) ; INT
(hdc-dst :pointer) ; HDC
(x :int32) ; INT
(y :int32) ; INT
(f-style :uint32)) ; IMAGE_LIST_DRAW_STYLE
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ImageList_Draw = Win32::API::More->new('COMCTL32',
'BOOL ImageList_Draw(LPARAM himl, int i, HANDLE hdcDst, int x, int y, DWORD fStyle)');
# my $ret = $ImageList_Draw->Call($himl, $i, $hdcDst, $x, $y, $fStyle);
# himl : HIMAGELIST -> LPARAM
# i : INT -> int
# hdcDst : HDC -> HANDLE
# x : INT -> int
# y : INT -> int
# fStyle : IMAGE_LIST_DRAW_STYLE -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
類似 API
- f ImageList_DrawEx — 色や効果を指定してイメージリストの画像を描画する。