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

GetThemeBackgroundRegion

関数
テーマ背景の領域(リージョン)を取得する。
DLLUxTheme.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

HRESULT GetThemeBackgroundRegion(
    HTHEME hTheme,
    HDC hdc,   // optional
    INT iPartId,
    INT iStateId,
    RECT* pRect,
    HRGN* pRegion
);

パラメーター

名前方向説明
hThemeHTHEMEin対象テーマデータのハンドル。
hdcHDCinoptional計算に使うデバイスコンテキストのハンドル。NULL可。
iPartIdINTin対象部品を識別するID。
iStateIdINTin部品の状態を識別するID。
pRectRECT*in背景を描画する矩形領域を指す入力RECTポインタ。
pRegionHRGN*out背景形状に対応するリージョンハンドルを受け取る出力ポインタ。呼出側で解放する。

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

GetThemeBackgroundRegion = ctypes.windll.uxtheme.GetThemeBackgroundRegion
GetThemeBackgroundRegion.restype = ctypes.c_int
GetThemeBackgroundRegion.argtypes = [
    ctypes.c_ssize_t,  # hTheme : HTHEME
    wintypes.HANDLE,  # hdc : HDC optional
    ctypes.c_int,  # iPartId : INT
    ctypes.c_int,  # iStateId : INT
    ctypes.c_void_p,  # pRect : RECT*
    ctypes.c_void_p,  # pRegion : HRGN* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	uxtheme = windows.NewLazySystemDLL("UxTheme.dll")
	procGetThemeBackgroundRegion = uxtheme.NewProc("GetThemeBackgroundRegion")
)

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