ホーム › UI.Controls › GetThemeBitmap
GetThemeBitmap
関数指定プロパティのテーマビットマップハンドルを取得する。
シグネチャ
// UXTHEME.dll
#include <windows.h>
HRESULT GetThemeBitmap(
HTHEME hTheme,
INT iPartId,
INT iStateId,
INT iPropId,
GET_THEME_BITMAP_FLAGS dwFlags,
HBITMAP* phBitmap
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| hTheme | HTHEME | in | テーマデータへのハンドル。 | ||||||||
| iPartId | INT | in | ビットマップを含むパーツ。Parts and States を参照してください。 | ||||||||
| iStateId | INT | in | パーツの状態。 | ||||||||
| iPropId | INT | in | 取得するプロパティ。ゼロを渡すと、このパーツと状態に対して最初に利用可能なビットマップが自動的に選択されます。 または、次のいずれかの値を使用します。
| ||||||||
| dwFlags | GET_THEME_BITMAP_FLAGS | in | ビットマップの取得方法を指定するフラグ。次のいずれかの値を指定できます。
| ||||||||
| phBitmap | HBITMAP* | out | 要求されたビットマップへのハンドルを受け取るポインター。 |
戻り値の型: HRESULT
公式ドキュメント
特定のテーマ、パーツ、状態、プロパティに関連付けられたビットマップを取得します。
戻り値
解説(Remarks)
dwFlags に GBF_COPY が設定されている場合は、phBitmap に格納されたビットマップが不要になった時点で DeleteObject を呼び出して解放してください。
出典・ライセンス: 上記「公式ドキュメント」の内容は 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 GetThemeBitmap(
HTHEME hTheme,
INT iPartId,
INT iStateId,
INT iPropId,
GET_THEME_BITMAP_FLAGS dwFlags,
HBITMAP* phBitmap
);[DllImport("UXTHEME.dll", ExactSpelling = true)]
static extern int GetThemeBitmap(
IntPtr hTheme, // HTHEME
int iPartId, // INT
int iStateId, // INT
int iPropId, // INT
uint dwFlags, // GET_THEME_BITMAP_FLAGS
IntPtr phBitmap // HBITMAP* out
);<DllImport("UXTHEME.dll", ExactSpelling:=True)>
Public Shared Function GetThemeBitmap(
hTheme As IntPtr, ' HTHEME
iPartId As Integer, ' INT
iStateId As Integer, ' INT
iPropId As Integer, ' INT
dwFlags As UInteger, ' GET_THEME_BITMAP_FLAGS
phBitmap As IntPtr ' HBITMAP* out
) As Integer
End Function' hTheme : HTHEME
' iPartId : INT
' iStateId : INT
' iPropId : INT
' dwFlags : GET_THEME_BITMAP_FLAGS
' phBitmap : HBITMAP* out
Declare PtrSafe Function GetThemeBitmap Lib "uxtheme" ( _
ByVal hTheme As LongPtr, _
ByVal iPartId As Long, _
ByVal iStateId As Long, _
ByVal iPropId As Long, _
ByVal dwFlags As Long, _
ByVal phBitmap As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetThemeBitmap = ctypes.windll.uxtheme.GetThemeBitmap
GetThemeBitmap.restype = ctypes.c_int
GetThemeBitmap.argtypes = [
ctypes.c_ssize_t, # hTheme : HTHEME
ctypes.c_int, # iPartId : INT
ctypes.c_int, # iStateId : INT
ctypes.c_int, # iPropId : INT
wintypes.DWORD, # dwFlags : GET_THEME_BITMAP_FLAGS
ctypes.c_void_p, # phBitmap : HBITMAP* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('UXTHEME.dll')
GetThemeBitmap = Fiddle::Function.new(
lib['GetThemeBitmap'],
[
Fiddle::TYPE_INTPTR_T, # hTheme : HTHEME
Fiddle::TYPE_INT, # iPartId : INT
Fiddle::TYPE_INT, # iStateId : INT
Fiddle::TYPE_INT, # iPropId : INT
-Fiddle::TYPE_INT, # dwFlags : GET_THEME_BITMAP_FLAGS
Fiddle::TYPE_VOIDP, # phBitmap : HBITMAP* out
],
Fiddle::TYPE_INT)#[link(name = "uxtheme")]
extern "system" {
fn GetThemeBitmap(
hTheme: isize, // HTHEME
iPartId: i32, // INT
iStateId: i32, // INT
iPropId: i32, // INT
dwFlags: u32, // GET_THEME_BITMAP_FLAGS
phBitmap: *mut *mut core::ffi::c_void // HBITMAP* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("UXTHEME.dll")]
public static extern int GetThemeBitmap(IntPtr hTheme, int iPartId, int iStateId, int iPropId, uint dwFlags, IntPtr phBitmap);
"@
$api = Add-Type -MemberDefinition $sig -Name 'UXTHEME_GetThemeBitmap' -Namespace Win32 -PassThru
# $api::GetThemeBitmap(hTheme, iPartId, iStateId, iPropId, dwFlags, phBitmap)#uselib "UXTHEME.dll"
#func global GetThemeBitmap "GetThemeBitmap" sptr, sptr, sptr, sptr, sptr, sptr
; GetThemeBitmap hTheme, iPartId, iStateId, iPropId, dwFlags, phBitmap ; 戻り値は stat
; hTheme : HTHEME -> "sptr"
; iPartId : INT -> "sptr"
; iStateId : INT -> "sptr"
; iPropId : INT -> "sptr"
; dwFlags : GET_THEME_BITMAP_FLAGS -> "sptr"
; phBitmap : HBITMAP* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "UXTHEME.dll"
#cfunc global GetThemeBitmap "GetThemeBitmap" sptr, int, int, int, int, sptr
; res = GetThemeBitmap(hTheme, iPartId, iStateId, iPropId, dwFlags, phBitmap)
; hTheme : HTHEME -> "sptr"
; iPartId : INT -> "int"
; iStateId : INT -> "int"
; iPropId : INT -> "int"
; dwFlags : GET_THEME_BITMAP_FLAGS -> "int"
; phBitmap : HBITMAP* out -> "sptr"; HRESULT GetThemeBitmap(HTHEME hTheme, INT iPartId, INT iStateId, INT iPropId, GET_THEME_BITMAP_FLAGS dwFlags, HBITMAP* phBitmap)
#uselib "UXTHEME.dll"
#cfunc global GetThemeBitmap "GetThemeBitmap" intptr, int, int, int, int, intptr
; res = GetThemeBitmap(hTheme, iPartId, iStateId, iPropId, dwFlags, phBitmap)
; hTheme : HTHEME -> "intptr"
; iPartId : INT -> "int"
; iStateId : INT -> "int"
; iPropId : INT -> "int"
; dwFlags : GET_THEME_BITMAP_FLAGS -> "int"
; phBitmap : HBITMAP* out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
uxtheme = windows.NewLazySystemDLL("UXTHEME.dll")
procGetThemeBitmap = uxtheme.NewProc("GetThemeBitmap")
)
// hTheme (HTHEME), iPartId (INT), iStateId (INT), iPropId (INT), dwFlags (GET_THEME_BITMAP_FLAGS), phBitmap (HBITMAP* out)
r1, _, err := procGetThemeBitmap.Call(
uintptr(hTheme),
uintptr(iPartId),
uintptr(iStateId),
uintptr(iPropId),
uintptr(dwFlags),
uintptr(phBitmap),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction GetThemeBitmap(
hTheme: NativeInt; // HTHEME
iPartId: Integer; // INT
iStateId: Integer; // INT
iPropId: Integer; // INT
dwFlags: DWORD; // GET_THEME_BITMAP_FLAGS
phBitmap: Pointer // HBITMAP* out
): Integer; stdcall;
external 'UXTHEME.dll' name 'GetThemeBitmap';result := DllCall("UXTHEME\GetThemeBitmap"
, "Ptr", hTheme ; HTHEME
, "Int", iPartId ; INT
, "Int", iStateId ; INT
, "Int", iPropId ; INT
, "UInt", dwFlags ; GET_THEME_BITMAP_FLAGS
, "Ptr", phBitmap ; HBITMAP* out
, "Int") ; return: HRESULT●GetThemeBitmap(hTheme, iPartId, iStateId, iPropId, dwFlags, phBitmap) = DLL("UXTHEME.dll", "int GetThemeBitmap(int, int, int, int, dword, void*)")
# 呼び出し: GetThemeBitmap(hTheme, iPartId, iStateId, iPropId, dwFlags, phBitmap)
# hTheme : HTHEME -> "int"
# iPartId : INT -> "int"
# iStateId : INT -> "int"
# iPropId : INT -> "int"
# dwFlags : GET_THEME_BITMAP_FLAGS -> "dword"
# phBitmap : HBITMAP* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "uxtheme" fn GetThemeBitmap(
hTheme: isize, // HTHEME
iPartId: i32, // INT
iStateId: i32, // INT
iPropId: i32, // INT
dwFlags: u32, // GET_THEME_BITMAP_FLAGS
phBitmap: ?*anyopaque // HBITMAP* out
) callconv(std.os.windows.WINAPI) i32;proc GetThemeBitmap(
hTheme: int, # HTHEME
iPartId: int32, # INT
iStateId: int32, # INT
iPropId: int32, # INT
dwFlags: uint32, # GET_THEME_BITMAP_FLAGS
phBitmap: pointer # HBITMAP* out
): int32 {.importc: "GetThemeBitmap", stdcall, dynlib: "UXTHEME.dll".}pragma(lib, "uxtheme");
extern(Windows)
int GetThemeBitmap(
ptrdiff_t hTheme, // HTHEME
int iPartId, // INT
int iStateId, // INT
int iPropId, // INT
uint dwFlags, // GET_THEME_BITMAP_FLAGS
void* phBitmap // HBITMAP* out
);ccall((:GetThemeBitmap, "UXTHEME.dll"), stdcall, Int32,
(Int, Int32, Int32, Int32, UInt32, Ptr{Cvoid}),
hTheme, iPartId, iStateId, iPropId, dwFlags, phBitmap)
# hTheme : HTHEME -> Int
# iPartId : INT -> Int32
# iStateId : INT -> Int32
# iPropId : INT -> Int32
# dwFlags : GET_THEME_BITMAP_FLAGS -> UInt32
# phBitmap : HBITMAP* out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t GetThemeBitmap(
intptr_t hTheme,
int32_t iPartId,
int32_t iStateId,
int32_t iPropId,
uint32_t dwFlags,
void* phBitmap);
]]
local uxtheme = ffi.load("uxtheme")
-- uxtheme.GetThemeBitmap(hTheme, iPartId, iStateId, iPropId, dwFlags, phBitmap)
-- hTheme : HTHEME
-- iPartId : INT
-- iStateId : INT
-- iPropId : INT
-- dwFlags : GET_THEME_BITMAP_FLAGS
-- phBitmap : HBITMAP* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('UXTHEME.dll');
const GetThemeBitmap = lib.func('__stdcall', 'GetThemeBitmap', 'int32_t', ['intptr_t', 'int32_t', 'int32_t', 'int32_t', 'uint32_t', 'void *']);
// GetThemeBitmap(hTheme, iPartId, iStateId, iPropId, dwFlags, phBitmap)
// hTheme : HTHEME -> 'intptr_t'
// iPartId : INT -> 'int32_t'
// iStateId : INT -> 'int32_t'
// iPropId : INT -> 'int32_t'
// dwFlags : GET_THEME_BITMAP_FLAGS -> 'uint32_t'
// phBitmap : HBITMAP* out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("UXTHEME.dll", {
GetThemeBitmap: { parameters: ["isize", "i32", "i32", "i32", "u32", "pointer"], result: "i32" },
});
// lib.symbols.GetThemeBitmap(hTheme, iPartId, iStateId, iPropId, dwFlags, phBitmap)
// hTheme : HTHEME -> "isize"
// iPartId : INT -> "i32"
// iStateId : INT -> "i32"
// iPropId : INT -> "i32"
// dwFlags : GET_THEME_BITMAP_FLAGS -> "u32"
// phBitmap : HBITMAP* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t GetThemeBitmap(
intptr_t hTheme,
int32_t iPartId,
int32_t iStateId,
int32_t iPropId,
uint32_t dwFlags,
void* phBitmap);
C, "UXTHEME.dll");
// $ffi->GetThemeBitmap(hTheme, iPartId, iStateId, iPropId, dwFlags, phBitmap);
// hTheme : HTHEME
// iPartId : INT
// iStateId : INT
// iPropId : INT
// dwFlags : GET_THEME_BITMAP_FLAGS
// phBitmap : HBITMAP* out
// 構造体/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 GetThemeBitmap(
long hTheme, // HTHEME
int iPartId, // INT
int iStateId, // INT
int iPropId, // INT
int dwFlags, // GET_THEME_BITMAP_FLAGS
Pointer phBitmap // HBITMAP* out
);
}@[Link("uxtheme")]
lib LibUXTHEME
fun GetThemeBitmap = GetThemeBitmap(
hTheme : LibC::SSizeT, # HTHEME
iPartId : Int32, # INT
iStateId : Int32, # INT
iPropId : Int32, # INT
dwFlags : UInt32, # GET_THEME_BITMAP_FLAGS
phBitmap : Void* # HBITMAP* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef GetThemeBitmapNative = Int32 Function(IntPtr, Int32, Int32, Int32, Uint32, Pointer<Void>);
typedef GetThemeBitmapDart = int Function(int, int, int, int, int, Pointer<Void>);
final GetThemeBitmap = DynamicLibrary.open('UXTHEME.dll')
.lookupFunction<GetThemeBitmapNative, GetThemeBitmapDart>('GetThemeBitmap');
// hTheme : HTHEME -> IntPtr
// iPartId : INT -> Int32
// iStateId : INT -> Int32
// iPropId : INT -> Int32
// dwFlags : GET_THEME_BITMAP_FLAGS -> Uint32
// phBitmap : HBITMAP* out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function GetThemeBitmap(
hTheme: NativeInt; // HTHEME
iPartId: Integer; // INT
iStateId: Integer; // INT
iPropId: Integer; // INT
dwFlags: DWORD; // GET_THEME_BITMAP_FLAGS
phBitmap: Pointer // HBITMAP* out
): Integer; stdcall;
external 'UXTHEME.dll' name 'GetThemeBitmap';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GetThemeBitmap"
c_GetThemeBitmap :: CIntPtr -> Int32 -> Int32 -> Int32 -> Word32 -> Ptr () -> IO Int32
-- hTheme : HTHEME -> CIntPtr
-- iPartId : INT -> Int32
-- iStateId : INT -> Int32
-- iPropId : INT -> Int32
-- dwFlags : GET_THEME_BITMAP_FLAGS -> Word32
-- phBitmap : HBITMAP* out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let getthemebitmap =
foreign "GetThemeBitmap"
(intptr_t @-> int32_t @-> int32_t @-> int32_t @-> uint32_t @-> (ptr void) @-> returning int32_t)
(* hTheme : HTHEME -> intptr_t *)
(* iPartId : INT -> int32_t *)
(* iStateId : INT -> int32_t *)
(* iPropId : INT -> int32_t *)
(* dwFlags : GET_THEME_BITMAP_FLAGS -> uint32_t *)
(* phBitmap : HBITMAP* out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library uxtheme (t "UXTHEME.dll"))
(cffi:use-foreign-library uxtheme)
(cffi:defcfun ("GetThemeBitmap" get-theme-bitmap :convention :stdcall) :int32
(h-theme :int64) ; HTHEME
(i-part-id :int32) ; INT
(i-state-id :int32) ; INT
(i-prop-id :int32) ; INT
(dw-flags :uint32) ; GET_THEME_BITMAP_FLAGS
(ph-bitmap :pointer)) ; HBITMAP* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $GetThemeBitmap = Win32::API::More->new('UXTHEME',
'int GetThemeBitmap(LPARAM hTheme, int iPartId, int iStateId, int iPropId, DWORD dwFlags, HANDLE phBitmap)');
# my $ret = $GetThemeBitmap->Call($hTheme, $iPartId, $iStateId, $iPropId, $dwFlags, $phBitmap);
# hTheme : HTHEME -> LPARAM
# iPartId : INT -> int
# iStateId : INT -> int
# iPropId : INT -> int
# dwFlags : GET_THEME_BITMAP_FLAGS -> DWORD
# phBitmap : HBITMAP* out -> HANDLE
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。