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

DrawThemeBackground

関数
指定パーツと状態のテーマ背景を矩形に描画する。
DLLUXTHEME.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

HRESULT DrawThemeBackground(
    HTHEME hTheme,
    HDC hdc,
    INT iPartId,
    INT iStateId,
    RECT* pRect,
    RECT* pClipRect   // optional
);

パラメーター

名前方向
hThemeHTHEMEin
hdcHDCin
iPartIdINTin
iStateIdINTin
pRectRECT*in
pClipRectRECT*inoptional

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT DrawThemeBackground(
    HTHEME hTheme,
    HDC hdc,
    INT iPartId,
    INT iStateId,
    RECT* pRect,
    RECT* pClipRect   // optional
);
[DllImport("UXTHEME.dll", ExactSpelling = true)]
static extern int DrawThemeBackground(
    IntPtr hTheme,   // HTHEME
    IntPtr hdc,   // HDC
    int iPartId,   // INT
    int iStateId,   // INT
    IntPtr pRect,   // RECT*
    IntPtr pClipRect   // RECT* optional
);
<DllImport("UXTHEME.dll", ExactSpelling:=True)>
Public Shared Function DrawThemeBackground(
    hTheme As IntPtr,   ' HTHEME
    hdc As IntPtr,   ' HDC
    iPartId As Integer,   ' INT
    iStateId As Integer,   ' INT
    pRect As IntPtr,   ' RECT*
    pClipRect As IntPtr   ' RECT* optional
) As Integer
End Function
' hTheme : HTHEME
' hdc : HDC
' iPartId : INT
' iStateId : INT
' pRect : RECT*
' pClipRect : RECT* optional
Declare PtrSafe Function DrawThemeBackground Lib "uxtheme" ( _
    ByVal hTheme As LongPtr, _
    ByVal hdc As LongPtr, _
    ByVal iPartId As Long, _
    ByVal iStateId As Long, _
    ByVal pRect As LongPtr, _
    ByVal pClipRect As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

DrawThemeBackground = ctypes.windll.uxtheme.DrawThemeBackground
DrawThemeBackground.restype = ctypes.c_int
DrawThemeBackground.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_void_p,  # pClipRect : RECT* optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('UXTHEME.dll')
DrawThemeBackground = Fiddle::Function.new(
  lib['DrawThemeBackground'],
  [
    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_VOIDP,  # pClipRect : RECT* optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "uxtheme")]
extern "system" {
    fn DrawThemeBackground(
        hTheme: isize,  // HTHEME
        hdc: *mut core::ffi::c_void,  // HDC
        iPartId: i32,  // INT
        iStateId: i32,  // INT
        pRect: *mut RECT,  // RECT*
        pClipRect: *mut RECT  // RECT* optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("UXTHEME.dll")]
public static extern int DrawThemeBackground(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, IntPtr pRect, IntPtr pClipRect);
"@
$api = Add-Type -MemberDefinition $sig -Name 'UXTHEME_DrawThemeBackground' -Namespace Win32 -PassThru
# $api::DrawThemeBackground(hTheme, hdc, iPartId, iStateId, pRect, pClipRect)
#uselib "UXTHEME.dll"
#func global DrawThemeBackground "DrawThemeBackground" sptr, sptr, sptr, sptr, sptr, sptr
; DrawThemeBackground hTheme, hdc, iPartId, iStateId, varptr(pRect), varptr(pClipRect)   ; 戻り値は stat
; hTheme : HTHEME -> "sptr"
; hdc : HDC -> "sptr"
; iPartId : INT -> "sptr"
; iStateId : INT -> "sptr"
; pRect : RECT* -> "sptr"
; pClipRect : RECT* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "UXTHEME.dll"
#cfunc global DrawThemeBackground "DrawThemeBackground" sptr, sptr, int, int, var, var
; res = DrawThemeBackground(hTheme, hdc, iPartId, iStateId, pRect, pClipRect)
; hTheme : HTHEME -> "sptr"
; hdc : HDC -> "sptr"
; iPartId : INT -> "int"
; iStateId : INT -> "int"
; pRect : RECT* -> "var"
; pClipRect : RECT* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT DrawThemeBackground(HTHEME hTheme, HDC hdc, INT iPartId, INT iStateId, RECT* pRect, RECT* pClipRect)
#uselib "UXTHEME.dll"
#cfunc global DrawThemeBackground "DrawThemeBackground" intptr, intptr, int, int, var, var
; res = DrawThemeBackground(hTheme, hdc, iPartId, iStateId, pRect, pClipRect)
; hTheme : HTHEME -> "intptr"
; hdc : HDC -> "intptr"
; iPartId : INT -> "int"
; iStateId : INT -> "int"
; pRect : RECT* -> "var"
; pClipRect : RECT* optional -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	uxtheme = windows.NewLazySystemDLL("UXTHEME.dll")
	procDrawThemeBackground = uxtheme.NewProc("DrawThemeBackground")
)

// hTheme (HTHEME), hdc (HDC), iPartId (INT), iStateId (INT), pRect (RECT*), pClipRect (RECT* optional)
r1, _, err := procDrawThemeBackground.Call(
	uintptr(hTheme),
	uintptr(hdc),
	uintptr(iPartId),
	uintptr(iStateId),
	uintptr(pRect),
	uintptr(pClipRect),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function DrawThemeBackground(
  hTheme: NativeInt;   // HTHEME
  hdc: THandle;   // HDC
  iPartId: Integer;   // INT
  iStateId: Integer;   // INT
  pRect: Pointer;   // RECT*
  pClipRect: Pointer   // RECT* optional
): Integer; stdcall;
  external 'UXTHEME.dll' name 'DrawThemeBackground';
result := DllCall("UXTHEME\DrawThemeBackground"
    , "Ptr", hTheme   ; HTHEME
    , "Ptr", hdc   ; HDC
    , "Int", iPartId   ; INT
    , "Int", iStateId   ; INT
    , "Ptr", pRect   ; RECT*
    , "Ptr", pClipRect   ; RECT* optional
    , "Int")   ; return: HRESULT
●DrawThemeBackground(hTheme, hdc, iPartId, iStateId, pRect, pClipRect) = DLL("UXTHEME.dll", "int DrawThemeBackground(int, void*, int, int, void*, void*)")
# 呼び出し: DrawThemeBackground(hTheme, hdc, iPartId, iStateId, pRect, pClipRect)
# hTheme : HTHEME -> "int"
# hdc : HDC -> "void*"
# iPartId : INT -> "int"
# iStateId : INT -> "int"
# pRect : RECT* -> "void*"
# pClipRect : RECT* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。