ホーム › UI.Controls › GetThemeMargins
GetThemeMargins
関数指定プロパティのテーマ余白(マージン)を取得する。
シグネチャ
// UXTHEME.dll
#include <windows.h>
HRESULT GetThemeMargins(
HTHEME hTheme,
HDC hdc, // optional
INT iPartId,
INT iStateId,
INT iPropId,
RECT* prc, // optional
MARGINS* pMargins
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hTheme | HTHEME | in |
| hdc | HDC | inoptional |
| iPartId | INT | in |
| iStateId | INT | in |
| iPropId | INT | in |
| prc | RECT* | inoptional |
| pMargins | MARGINS* | out |
戻り値の型: HRESULT
各言語での呼び出し定義
// UXTHEME.dll
#include <windows.h>
HRESULT GetThemeMargins(
HTHEME hTheme,
HDC hdc, // optional
INT iPartId,
INT iStateId,
INT iPropId,
RECT* prc, // optional
MARGINS* pMargins
);[DllImport("UXTHEME.dll", ExactSpelling = true)]
static extern int GetThemeMargins(
IntPtr hTheme, // HTHEME
IntPtr hdc, // HDC optional
int iPartId, // INT
int iStateId, // INT
int iPropId, // INT
IntPtr prc, // RECT* optional
IntPtr pMargins // MARGINS* out
);<DllImport("UXTHEME.dll", ExactSpelling:=True)>
Public Shared Function GetThemeMargins(
hTheme As IntPtr, ' HTHEME
hdc As IntPtr, ' HDC optional
iPartId As Integer, ' INT
iStateId As Integer, ' INT
iPropId As Integer, ' INT
prc As IntPtr, ' RECT* optional
pMargins As IntPtr ' MARGINS* out
) As Integer
End Function' hTheme : HTHEME
' hdc : HDC optional
' iPartId : INT
' iStateId : INT
' iPropId : INT
' prc : RECT* optional
' pMargins : MARGINS* out
Declare PtrSafe Function GetThemeMargins Lib "uxtheme" ( _
ByVal hTheme As LongPtr, _
ByVal hdc As LongPtr, _
ByVal iPartId As Long, _
ByVal iStateId As Long, _
ByVal iPropId As Long, _
ByVal prc As LongPtr, _
ByVal pMargins As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetThemeMargins = ctypes.windll.uxtheme.GetThemeMargins
GetThemeMargins.restype = ctypes.c_int
GetThemeMargins.argtypes = [
ctypes.c_ssize_t, # hTheme : HTHEME
wintypes.HANDLE, # hdc : HDC optional
ctypes.c_int, # iPartId : INT
ctypes.c_int, # iStateId : INT
ctypes.c_int, # iPropId : INT
ctypes.c_void_p, # prc : RECT* optional
ctypes.c_void_p, # pMargins : MARGINS* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('UXTHEME.dll')
GetThemeMargins = Fiddle::Function.new(
lib['GetThemeMargins'],
[
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, # iPropId : INT
Fiddle::TYPE_VOIDP, # prc : RECT* optional
Fiddle::TYPE_VOIDP, # pMargins : MARGINS* out
],
Fiddle::TYPE_INT)#[link(name = "uxtheme")]
extern "system" {
fn GetThemeMargins(
hTheme: isize, // HTHEME
hdc: *mut core::ffi::c_void, // HDC optional
iPartId: i32, // INT
iStateId: i32, // INT
iPropId: i32, // INT
prc: *mut RECT, // RECT* optional
pMargins: *mut MARGINS // MARGINS* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("UXTHEME.dll")]
public static extern int GetThemeMargins(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, int iPropId, IntPtr prc, IntPtr pMargins);
"@
$api = Add-Type -MemberDefinition $sig -Name 'UXTHEME_GetThemeMargins' -Namespace Win32 -PassThru
# $api::GetThemeMargins(hTheme, hdc, iPartId, iStateId, iPropId, prc, pMargins)#uselib "UXTHEME.dll"
#func global GetThemeMargins "GetThemeMargins" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; GetThemeMargins hTheme, hdc, iPartId, iStateId, iPropId, varptr(prc), varptr(pMargins) ; 戻り値は stat
; hTheme : HTHEME -> "sptr"
; hdc : HDC optional -> "sptr"
; iPartId : INT -> "sptr"
; iStateId : INT -> "sptr"
; iPropId : INT -> "sptr"
; prc : RECT* optional -> "sptr"
; pMargins : MARGINS* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "UXTHEME.dll" #cfunc global GetThemeMargins "GetThemeMargins" sptr, sptr, int, int, int, var, var ; res = GetThemeMargins(hTheme, hdc, iPartId, iStateId, iPropId, prc, pMargins) ; hTheme : HTHEME -> "sptr" ; hdc : HDC optional -> "sptr" ; iPartId : INT -> "int" ; iStateId : INT -> "int" ; iPropId : INT -> "int" ; prc : RECT* optional -> "var" ; pMargins : MARGINS* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "UXTHEME.dll" #cfunc global GetThemeMargins "GetThemeMargins" sptr, sptr, int, int, int, sptr, sptr ; res = GetThemeMargins(hTheme, hdc, iPartId, iStateId, iPropId, varptr(prc), varptr(pMargins)) ; hTheme : HTHEME -> "sptr" ; hdc : HDC optional -> "sptr" ; iPartId : INT -> "int" ; iStateId : INT -> "int" ; iPropId : INT -> "int" ; prc : RECT* optional -> "sptr" ; pMargins : MARGINS* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT GetThemeMargins(HTHEME hTheme, HDC hdc, INT iPartId, INT iStateId, INT iPropId, RECT* prc, MARGINS* pMargins) #uselib "UXTHEME.dll" #cfunc global GetThemeMargins "GetThemeMargins" intptr, intptr, int, int, int, var, var ; res = GetThemeMargins(hTheme, hdc, iPartId, iStateId, iPropId, prc, pMargins) ; hTheme : HTHEME -> "intptr" ; hdc : HDC optional -> "intptr" ; iPartId : INT -> "int" ; iStateId : INT -> "int" ; iPropId : INT -> "int" ; prc : RECT* optional -> "var" ; pMargins : MARGINS* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT GetThemeMargins(HTHEME hTheme, HDC hdc, INT iPartId, INT iStateId, INT iPropId, RECT* prc, MARGINS* pMargins) #uselib "UXTHEME.dll" #cfunc global GetThemeMargins "GetThemeMargins" intptr, intptr, int, int, int, intptr, intptr ; res = GetThemeMargins(hTheme, hdc, iPartId, iStateId, iPropId, varptr(prc), varptr(pMargins)) ; hTheme : HTHEME -> "intptr" ; hdc : HDC optional -> "intptr" ; iPartId : INT -> "int" ; iStateId : INT -> "int" ; iPropId : INT -> "int" ; prc : RECT* optional -> "intptr" ; pMargins : MARGINS* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
uxtheme = windows.NewLazySystemDLL("UXTHEME.dll")
procGetThemeMargins = uxtheme.NewProc("GetThemeMargins")
)
// hTheme (HTHEME), hdc (HDC optional), iPartId (INT), iStateId (INT), iPropId (INT), prc (RECT* optional), pMargins (MARGINS* out)
r1, _, err := procGetThemeMargins.Call(
uintptr(hTheme),
uintptr(hdc),
uintptr(iPartId),
uintptr(iStateId),
uintptr(iPropId),
uintptr(prc),
uintptr(pMargins),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction GetThemeMargins(
hTheme: NativeInt; // HTHEME
hdc: THandle; // HDC optional
iPartId: Integer; // INT
iStateId: Integer; // INT
iPropId: Integer; // INT
prc: Pointer; // RECT* optional
pMargins: Pointer // MARGINS* out
): Integer; stdcall;
external 'UXTHEME.dll' name 'GetThemeMargins';result := DllCall("UXTHEME\GetThemeMargins"
, "Ptr", hTheme ; HTHEME
, "Ptr", hdc ; HDC optional
, "Int", iPartId ; INT
, "Int", iStateId ; INT
, "Int", iPropId ; INT
, "Ptr", prc ; RECT* optional
, "Ptr", pMargins ; MARGINS* out
, "Int") ; return: HRESULT●GetThemeMargins(hTheme, hdc, iPartId, iStateId, iPropId, prc, pMargins) = DLL("UXTHEME.dll", "int GetThemeMargins(int, void*, int, int, int, void*, void*)")
# 呼び出し: GetThemeMargins(hTheme, hdc, iPartId, iStateId, iPropId, prc, pMargins)
# hTheme : HTHEME -> "int"
# hdc : HDC optional -> "void*"
# iPartId : INT -> "int"
# iStateId : INT -> "int"
# iPropId : INT -> "int"
# prc : RECT* optional -> "void*"
# pMargins : MARGINS* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。