ホーム › UI.Controls › DrawThemeIcon
DrawThemeIcon
関数イメージリスト内のアイコンをテーマに従って描画する。
シグネチャ
// UXTHEME.dll
#include <windows.h>
HRESULT DrawThemeIcon(
HTHEME hTheme,
HDC hdc,
INT iPartId,
INT iStateId,
RECT* pRect,
HIMAGELIST himl,
INT iImageIndex
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hTheme | HTHEME | in | ウィンドウの指定されたテーマデータへのハンドル。HTHEME を作成するには OpenThemeData を使用します。 |
| hdc | HDC | in | HDC。 |
| iPartId | INT | in | イメージを描画するパートを指定する int 型の値。Parts and States を参照してください。 |
| iStateId | INT | in | パートの状態を指定する int 型の値。Parts and States を参照してください。 |
| pRect | RECT* | in | イメージを描画する矩形を論理座標で格納する RECT 構造体へのポインター。 |
| himl | HIMAGELIST | in | 描画するイメージを格納する イメージリスト へのハンドル。 |
| iImageIndex | INT | in | 描画するイメージのインデックスを指定する int 型の値。 |
戻り値の型: HRESULT
公式ドキュメント
ビジュアルスタイルで定義されたアイコン効果を適用して、イメージリストのイメージを描画します。
戻り値
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// UXTHEME.dll
#include <windows.h>
HRESULT DrawThemeIcon(
HTHEME hTheme,
HDC hdc,
INT iPartId,
INT iStateId,
RECT* pRect,
HIMAGELIST himl,
INT iImageIndex
);[DllImport("UXTHEME.dll", ExactSpelling = true)]
static extern int DrawThemeIcon(
IntPtr hTheme, // HTHEME
IntPtr hdc, // HDC
int iPartId, // INT
int iStateId, // INT
IntPtr pRect, // RECT*
IntPtr himl, // HIMAGELIST
int iImageIndex // INT
);<DllImport("UXTHEME.dll", ExactSpelling:=True)>
Public Shared Function DrawThemeIcon(
hTheme As IntPtr, ' HTHEME
hdc As IntPtr, ' HDC
iPartId As Integer, ' INT
iStateId As Integer, ' INT
pRect As IntPtr, ' RECT*
himl As IntPtr, ' HIMAGELIST
iImageIndex As Integer ' INT
) As Integer
End Function' hTheme : HTHEME
' hdc : HDC
' iPartId : INT
' iStateId : INT
' pRect : RECT*
' himl : HIMAGELIST
' iImageIndex : INT
Declare PtrSafe Function DrawThemeIcon Lib "uxtheme" ( _
ByVal hTheme As LongPtr, _
ByVal hdc As LongPtr, _
ByVal iPartId As Long, _
ByVal iStateId As Long, _
ByVal pRect As LongPtr, _
ByVal himl As LongPtr, _
ByVal iImageIndex As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DrawThemeIcon = ctypes.windll.uxtheme.DrawThemeIcon
DrawThemeIcon.restype = ctypes.c_int
DrawThemeIcon.argtypes = [
ctypes.c_ssize_t, # hTheme : HTHEME
wintypes.HANDLE, # hdc : HDC
ctypes.c_int, # iPartId : INT
ctypes.c_int, # iStateId : INT
ctypes.c_void_p, # pRect : RECT*
ctypes.c_ssize_t, # himl : HIMAGELIST
ctypes.c_int, # iImageIndex : INT
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('UXTHEME.dll')
DrawThemeIcon = Fiddle::Function.new(
lib['DrawThemeIcon'],
[
Fiddle::TYPE_INTPTR_T, # hTheme : HTHEME
Fiddle::TYPE_VOIDP, # hdc : HDC
Fiddle::TYPE_INT, # iPartId : INT
Fiddle::TYPE_INT, # iStateId : INT
Fiddle::TYPE_VOIDP, # pRect : RECT*
Fiddle::TYPE_INTPTR_T, # himl : HIMAGELIST
Fiddle::TYPE_INT, # iImageIndex : INT
],
Fiddle::TYPE_INT)#[link(name = "uxtheme")]
extern "system" {
fn DrawThemeIcon(
hTheme: isize, // HTHEME
hdc: *mut core::ffi::c_void, // HDC
iPartId: i32, // INT
iStateId: i32, // INT
pRect: *mut RECT, // RECT*
himl: isize, // HIMAGELIST
iImageIndex: i32 // INT
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("UXTHEME.dll")]
public static extern int DrawThemeIcon(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, IntPtr pRect, IntPtr himl, int iImageIndex);
"@
$api = Add-Type -MemberDefinition $sig -Name 'UXTHEME_DrawThemeIcon' -Namespace Win32 -PassThru
# $api::DrawThemeIcon(hTheme, hdc, iPartId, iStateId, pRect, himl, iImageIndex)#uselib "UXTHEME.dll"
#func global DrawThemeIcon "DrawThemeIcon" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; DrawThemeIcon hTheme, hdc, iPartId, iStateId, varptr(pRect), himl, iImageIndex ; 戻り値は stat
; hTheme : HTHEME -> "sptr"
; hdc : HDC -> "sptr"
; iPartId : INT -> "sptr"
; iStateId : INT -> "sptr"
; pRect : RECT* -> "sptr"
; himl : HIMAGELIST -> "sptr"
; iImageIndex : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "UXTHEME.dll" #cfunc global DrawThemeIcon "DrawThemeIcon" sptr, sptr, int, int, var, sptr, int ; res = DrawThemeIcon(hTheme, hdc, iPartId, iStateId, pRect, himl, iImageIndex) ; hTheme : HTHEME -> "sptr" ; hdc : HDC -> "sptr" ; iPartId : INT -> "int" ; iStateId : INT -> "int" ; pRect : RECT* -> "var" ; himl : HIMAGELIST -> "sptr" ; iImageIndex : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "UXTHEME.dll" #cfunc global DrawThemeIcon "DrawThemeIcon" sptr, sptr, int, int, sptr, sptr, int ; res = DrawThemeIcon(hTheme, hdc, iPartId, iStateId, varptr(pRect), himl, iImageIndex) ; hTheme : HTHEME -> "sptr" ; hdc : HDC -> "sptr" ; iPartId : INT -> "int" ; iStateId : INT -> "int" ; pRect : RECT* -> "sptr" ; himl : HIMAGELIST -> "sptr" ; iImageIndex : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT DrawThemeIcon(HTHEME hTheme, HDC hdc, INT iPartId, INT iStateId, RECT* pRect, HIMAGELIST himl, INT iImageIndex) #uselib "UXTHEME.dll" #cfunc global DrawThemeIcon "DrawThemeIcon" intptr, intptr, int, int, var, intptr, int ; res = DrawThemeIcon(hTheme, hdc, iPartId, iStateId, pRect, himl, iImageIndex) ; hTheme : HTHEME -> "intptr" ; hdc : HDC -> "intptr" ; iPartId : INT -> "int" ; iStateId : INT -> "int" ; pRect : RECT* -> "var" ; himl : HIMAGELIST -> "intptr" ; iImageIndex : INT -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT DrawThemeIcon(HTHEME hTheme, HDC hdc, INT iPartId, INT iStateId, RECT* pRect, HIMAGELIST himl, INT iImageIndex) #uselib "UXTHEME.dll" #cfunc global DrawThemeIcon "DrawThemeIcon" intptr, intptr, int, int, intptr, intptr, int ; res = DrawThemeIcon(hTheme, hdc, iPartId, iStateId, varptr(pRect), himl, iImageIndex) ; hTheme : HTHEME -> "intptr" ; hdc : HDC -> "intptr" ; iPartId : INT -> "int" ; iStateId : INT -> "int" ; pRect : RECT* -> "intptr" ; himl : HIMAGELIST -> "intptr" ; iImageIndex : INT -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
uxtheme = windows.NewLazySystemDLL("UXTHEME.dll")
procDrawThemeIcon = uxtheme.NewProc("DrawThemeIcon")
)
// hTheme (HTHEME), hdc (HDC), iPartId (INT), iStateId (INT), pRect (RECT*), himl (HIMAGELIST), iImageIndex (INT)
r1, _, err := procDrawThemeIcon.Call(
uintptr(hTheme),
uintptr(hdc),
uintptr(iPartId),
uintptr(iStateId),
uintptr(pRect),
uintptr(himl),
uintptr(iImageIndex),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction DrawThemeIcon(
hTheme: NativeInt; // HTHEME
hdc: THandle; // HDC
iPartId: Integer; // INT
iStateId: Integer; // INT
pRect: Pointer; // RECT*
himl: NativeInt; // HIMAGELIST
iImageIndex: Integer // INT
): Integer; stdcall;
external 'UXTHEME.dll' name 'DrawThemeIcon';result := DllCall("UXTHEME\DrawThemeIcon"
, "Ptr", hTheme ; HTHEME
, "Ptr", hdc ; HDC
, "Int", iPartId ; INT
, "Int", iStateId ; INT
, "Ptr", pRect ; RECT*
, "Ptr", himl ; HIMAGELIST
, "Int", iImageIndex ; INT
, "Int") ; return: HRESULT●DrawThemeIcon(hTheme, hdc, iPartId, iStateId, pRect, himl, iImageIndex) = DLL("UXTHEME.dll", "int DrawThemeIcon(int, void*, int, int, void*, int, int)")
# 呼び出し: DrawThemeIcon(hTheme, hdc, iPartId, iStateId, pRect, himl, iImageIndex)
# hTheme : HTHEME -> "int"
# hdc : HDC -> "void*"
# iPartId : INT -> "int"
# iStateId : INT -> "int"
# pRect : RECT* -> "void*"
# himl : HIMAGELIST -> "int"
# iImageIndex : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "uxtheme" fn DrawThemeIcon(
hTheme: isize, // HTHEME
hdc: ?*anyopaque, // HDC
iPartId: i32, // INT
iStateId: i32, // INT
pRect: [*c]RECT, // RECT*
himl: isize, // HIMAGELIST
iImageIndex: i32 // INT
) callconv(std.os.windows.WINAPI) i32;proc DrawThemeIcon(
hTheme: int, # HTHEME
hdc: pointer, # HDC
iPartId: int32, # INT
iStateId: int32, # INT
pRect: ptr RECT, # RECT*
himl: int, # HIMAGELIST
iImageIndex: int32 # INT
): int32 {.importc: "DrawThemeIcon", stdcall, dynlib: "UXTHEME.dll".}pragma(lib, "uxtheme");
extern(Windows)
int DrawThemeIcon(
ptrdiff_t hTheme, // HTHEME
void* hdc, // HDC
int iPartId, // INT
int iStateId, // INT
RECT* pRect, // RECT*
ptrdiff_t himl, // HIMAGELIST
int iImageIndex // INT
);ccall((:DrawThemeIcon, "UXTHEME.dll"), stdcall, Int32,
(Int, Ptr{Cvoid}, Int32, Int32, Ptr{RECT}, Int, Int32),
hTheme, hdc, iPartId, iStateId, pRect, himl, iImageIndex)
# hTheme : HTHEME -> Int
# hdc : HDC -> Ptr{Cvoid}
# iPartId : INT -> Int32
# iStateId : INT -> Int32
# pRect : RECT* -> Ptr{RECT}
# himl : HIMAGELIST -> Int
# iImageIndex : INT -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t DrawThemeIcon(
intptr_t hTheme,
void* hdc,
int32_t iPartId,
int32_t iStateId,
void* pRect,
intptr_t himl,
int32_t iImageIndex);
]]
local uxtheme = ffi.load("uxtheme")
-- uxtheme.DrawThemeIcon(hTheme, hdc, iPartId, iStateId, pRect, himl, iImageIndex)
-- hTheme : HTHEME
-- hdc : HDC
-- iPartId : INT
-- iStateId : INT
-- pRect : RECT*
-- himl : HIMAGELIST
-- iImageIndex : INT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('UXTHEME.dll');
const DrawThemeIcon = lib.func('__stdcall', 'DrawThemeIcon', 'int32_t', ['intptr_t', 'void *', 'int32_t', 'int32_t', 'void *', 'intptr_t', 'int32_t']);
// DrawThemeIcon(hTheme, hdc, iPartId, iStateId, pRect, himl, iImageIndex)
// hTheme : HTHEME -> 'intptr_t'
// hdc : HDC -> 'void *'
// iPartId : INT -> 'int32_t'
// iStateId : INT -> 'int32_t'
// pRect : RECT* -> 'void *'
// himl : HIMAGELIST -> 'intptr_t'
// iImageIndex : INT -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("UXTHEME.dll", {
DrawThemeIcon: { parameters: ["isize", "pointer", "i32", "i32", "pointer", "isize", "i32"], result: "i32" },
});
// lib.symbols.DrawThemeIcon(hTheme, hdc, iPartId, iStateId, pRect, himl, iImageIndex)
// hTheme : HTHEME -> "isize"
// hdc : HDC -> "pointer"
// iPartId : INT -> "i32"
// iStateId : INT -> "i32"
// pRect : RECT* -> "pointer"
// himl : HIMAGELIST -> "isize"
// iImageIndex : INT -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t DrawThemeIcon(
intptr_t hTheme,
void* hdc,
int32_t iPartId,
int32_t iStateId,
void* pRect,
intptr_t himl,
int32_t iImageIndex);
C, "UXTHEME.dll");
// $ffi->DrawThemeIcon(hTheme, hdc, iPartId, iStateId, pRect, himl, iImageIndex);
// hTheme : HTHEME
// hdc : HDC
// iPartId : INT
// iStateId : INT
// pRect : RECT*
// himl : HIMAGELIST
// iImageIndex : INT
// 構造体/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 Uxtheme extends StdCallLibrary {
Uxtheme INSTANCE = Native.load("uxtheme", Uxtheme.class);
int DrawThemeIcon(
long hTheme, // HTHEME
Pointer hdc, // HDC
int iPartId, // INT
int iStateId, // INT
Pointer pRect, // RECT*
long himl, // HIMAGELIST
int iImageIndex // INT
);
}@[Link("uxtheme")]
lib LibUXTHEME
fun DrawThemeIcon = DrawThemeIcon(
hTheme : LibC::SSizeT, # HTHEME
hdc : Void*, # HDC
iPartId : Int32, # INT
iStateId : Int32, # INT
pRect : RECT*, # RECT*
himl : LibC::SSizeT, # HIMAGELIST
iImageIndex : Int32 # INT
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef DrawThemeIconNative = Int32 Function(IntPtr, Pointer<Void>, Int32, Int32, Pointer<Void>, IntPtr, Int32);
typedef DrawThemeIconDart = int Function(int, Pointer<Void>, int, int, Pointer<Void>, int, int);
final DrawThemeIcon = DynamicLibrary.open('UXTHEME.dll')
.lookupFunction<DrawThemeIconNative, DrawThemeIconDart>('DrawThemeIcon');
// hTheme : HTHEME -> IntPtr
// hdc : HDC -> Pointer<Void>
// iPartId : INT -> Int32
// iStateId : INT -> Int32
// pRect : RECT* -> Pointer<Void>
// himl : HIMAGELIST -> IntPtr
// iImageIndex : INT -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function DrawThemeIcon(
hTheme: NativeInt; // HTHEME
hdc: THandle; // HDC
iPartId: Integer; // INT
iStateId: Integer; // INT
pRect: Pointer; // RECT*
himl: NativeInt; // HIMAGELIST
iImageIndex: Integer // INT
): Integer; stdcall;
external 'UXTHEME.dll' name 'DrawThemeIcon';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "DrawThemeIcon"
c_DrawThemeIcon :: CIntPtr -> Ptr () -> Int32 -> Int32 -> Ptr () -> CIntPtr -> Int32 -> IO Int32
-- hTheme : HTHEME -> CIntPtr
-- hdc : HDC -> Ptr ()
-- iPartId : INT -> Int32
-- iStateId : INT -> Int32
-- pRect : RECT* -> Ptr ()
-- himl : HIMAGELIST -> CIntPtr
-- iImageIndex : INT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let drawthemeicon =
foreign "DrawThemeIcon"
(intptr_t @-> (ptr void) @-> int32_t @-> int32_t @-> (ptr void) @-> intptr_t @-> int32_t @-> returning int32_t)
(* hTheme : HTHEME -> intptr_t *)
(* hdc : HDC -> (ptr void) *)
(* iPartId : INT -> int32_t *)
(* iStateId : INT -> int32_t *)
(* pRect : RECT* -> (ptr void) *)
(* himl : HIMAGELIST -> intptr_t *)
(* iImageIndex : INT -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library uxtheme (t "UXTHEME.dll"))
(cffi:use-foreign-library uxtheme)
(cffi:defcfun ("DrawThemeIcon" draw-theme-icon :convention :stdcall) :int32
(h-theme :int64) ; HTHEME
(hdc :pointer) ; HDC
(i-part-id :int32) ; INT
(i-state-id :int32) ; INT
(p-rect :pointer) ; RECT*
(himl :int64) ; HIMAGELIST
(i-image-index :int32)) ; INT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $DrawThemeIcon = Win32::API::More->new('UXTHEME',
'int DrawThemeIcon(LPARAM hTheme, HANDLE hdc, int iPartId, int iStateId, LPVOID pRect, LPARAM himl, int iImageIndex)');
# my $ret = $DrawThemeIcon->Call($hTheme, $hdc, $iPartId, $iStateId, $pRect, $himl, $iImageIndex);
# hTheme : HTHEME -> LPARAM
# hdc : HDC -> HANDLE
# iPartId : INT -> int
# iStateId : INT -> int
# pRect : RECT* -> LPVOID
# himl : HIMAGELIST -> LPARAM
# iImageIndex : INT -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
公式の関連項目
使用する型