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

DrawThemeBackgroundEx

関数
オプション指定でテーマ背景を矩形に描画する拡張版。
DLLUXTHEME.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

HRESULT DrawThemeBackgroundEx(
    HTHEME hTheme,
    HDC hdc,
    INT iPartId,
    INT iStateId,
    RECT* pRect,
    const DTBGOPTS* pOptions   // optional
);

パラメーター

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

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

DrawThemeBackgroundEx = ctypes.windll.uxtheme.DrawThemeBackgroundEx
DrawThemeBackgroundEx.restype = ctypes.c_int
DrawThemeBackgroundEx.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,  # pOptions : DTBGOPTS* optional
]
require 'fiddle'
require 'fiddle/import'

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

var (
	uxtheme = windows.NewLazySystemDLL("UXTHEME.dll")
	procDrawThemeBackgroundEx = uxtheme.NewProc("DrawThemeBackgroundEx")
)

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