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

HitTestThemeBackground

関数
テーマ背景に対する指定座標のヒットテストを行いコードを返す。
DLLUxTheme.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

HRESULT HitTestThemeBackground(
    HTHEME hTheme,
    HDC hdc,   // optional
    INT iPartId,
    INT iStateId,
    HIT_TEST_BACKGROUND_OPTIONS dwOptions,
    RECT* pRect,
    HRGN hrgn,   // optional
    POINT ptTest,
    WORD* pwHitTestCode
);

パラメーター

名前方向
hThemeHTHEMEin
hdcHDCinoptional
iPartIdINTin
iStateIdINTin
dwOptionsHIT_TEST_BACKGROUND_OPTIONSin
pRectRECT*in
hrgnHRGNinoptional
ptTestPOINTin
pwHitTestCodeWORD*out

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

HitTestThemeBackground = ctypes.windll.uxtheme.HitTestThemeBackground
HitTestThemeBackground.restype = ctypes.c_int
HitTestThemeBackground.argtypes = [
    ctypes.c_ssize_t,  # hTheme : HTHEME
    wintypes.HANDLE,  # hdc : HDC optional
    ctypes.c_int,  # iPartId : INT
    ctypes.c_int,  # iStateId : INT
    wintypes.DWORD,  # dwOptions : HIT_TEST_BACKGROUND_OPTIONS
    ctypes.c_void_p,  # pRect : RECT*
    wintypes.HANDLE,  # hrgn : HRGN optional
    POINT,  # ptTest : POINT
    ctypes.POINTER(ctypes.c_ushort),  # pwHitTestCode : WORD* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	uxtheme = windows.NewLazySystemDLL("UxTheme.dll")
	procHitTestThemeBackground = uxtheme.NewProc("HitTestThemeBackground")
)

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