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

GetThemeBitmap

関数
指定プロパティのテーマビットマップハンドルを取得する。
DLLUXTHEME.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

HRESULT GetThemeBitmap(
    HTHEME hTheme,
    INT iPartId,
    INT iStateId,
    INT iPropId,
    GET_THEME_BITMAP_FLAGS dwFlags,
    HBITMAP* phBitmap
);

パラメーター

名前方向
hThemeHTHEMEin
iPartIdINTin
iStateIdINTin
iPropIdINTin
dwFlagsGET_THEME_BITMAP_FLAGSin
phBitmapHBITMAP*out

戻り値の型: HRESULT

各言語での呼び出し定義

// 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   // HRESULT
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';
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)。