ホーム › UI.Controls › GetThemePartSize
GetThemePartSize
関数指定パーツと状態のテーマ要素のサイズを取得する。
シグネチャ
// UXTHEME.dll
#include <windows.h>
HRESULT GetThemePartSize(
HTHEME hTheme,
HDC hdc, // optional
INT iPartId,
INT iStateId,
RECT* prc, // optional
THEMESIZE eSize,
SIZE* psz
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hTheme | HTHEME | in | ウィンドウに指定されたテーマデータへのハンドル。HTHEME を作成するには OpenThemeData を使用します。 |
| hdc | HDC | inoptional | フォントを選択する対象の HDC。 |
| iPartId | INT | in | サイズを計算するパーツを指定する int 型の値。Parts and States を参照してください。 |
| iStateId | INT | in | パーツの状態を指定する int 型の値。Parts and States を参照してください。 |
| prc | RECT* | inoptional | パーツの描画先として使用される矩形を格納する RECT 構造体へのポインター。このパラメーターには NULL を設定できます。 |
| eSize | THEMESIZE | in | 取得するサイズの種類を指定する列挙型。型の値の一覧については THEMESIZE を参照してください。 |
| psz | SIZE* | out | 指定したパーツの寸法を受け取る SIZE 構造体へのポインター。 |
戻り値の型: HRESULT
公式ドキュメント
ビジュアルスタイルで定義されたパーツの元のサイズを計算します。
戻り値
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// UXTHEME.dll
#include <windows.h>
HRESULT GetThemePartSize(
HTHEME hTheme,
HDC hdc, // optional
INT iPartId,
INT iStateId,
RECT* prc, // optional
THEMESIZE eSize,
SIZE* psz
);[DllImport("UXTHEME.dll", ExactSpelling = true)]
static extern int GetThemePartSize(
IntPtr hTheme, // HTHEME
IntPtr hdc, // HDC optional
int iPartId, // INT
int iStateId, // INT
IntPtr prc, // RECT* optional
int eSize, // THEMESIZE
IntPtr psz // SIZE* out
);<DllImport("UXTHEME.dll", ExactSpelling:=True)>
Public Shared Function GetThemePartSize(
hTheme As IntPtr, ' HTHEME
hdc As IntPtr, ' HDC optional
iPartId As Integer, ' INT
iStateId As Integer, ' INT
prc As IntPtr, ' RECT* optional
eSize As Integer, ' THEMESIZE
psz As IntPtr ' SIZE* out
) As Integer
End Function' hTheme : HTHEME
' hdc : HDC optional
' iPartId : INT
' iStateId : INT
' prc : RECT* optional
' eSize : THEMESIZE
' psz : SIZE* out
Declare PtrSafe Function GetThemePartSize Lib "uxtheme" ( _
ByVal hTheme As LongPtr, _
ByVal hdc As LongPtr, _
ByVal iPartId As Long, _
ByVal iStateId As Long, _
ByVal prc As LongPtr, _
ByVal eSize As Long, _
ByVal psz As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetThemePartSize = ctypes.windll.uxtheme.GetThemePartSize
GetThemePartSize.restype = ctypes.c_int
GetThemePartSize.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, # prc : RECT* optional
ctypes.c_int, # eSize : THEMESIZE
ctypes.c_void_p, # psz : SIZE* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('UXTHEME.dll')
GetThemePartSize = Fiddle::Function.new(
lib['GetThemePartSize'],
[
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, # prc : RECT* optional
Fiddle::TYPE_INT, # eSize : THEMESIZE
Fiddle::TYPE_VOIDP, # psz : SIZE* out
],
Fiddle::TYPE_INT)#[link(name = "uxtheme")]
extern "system" {
fn GetThemePartSize(
hTheme: isize, // HTHEME
hdc: *mut core::ffi::c_void, // HDC optional
iPartId: i32, // INT
iStateId: i32, // INT
prc: *mut RECT, // RECT* optional
eSize: i32, // THEMESIZE
psz: *mut SIZE // SIZE* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("UXTHEME.dll")]
public static extern int GetThemePartSize(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, IntPtr prc, int eSize, IntPtr psz);
"@
$api = Add-Type -MemberDefinition $sig -Name 'UXTHEME_GetThemePartSize' -Namespace Win32 -PassThru
# $api::GetThemePartSize(hTheme, hdc, iPartId, iStateId, prc, eSize, psz)#uselib "UXTHEME.dll"
#func global GetThemePartSize "GetThemePartSize" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; GetThemePartSize hTheme, hdc, iPartId, iStateId, varptr(prc), eSize, varptr(psz) ; 戻り値は stat
; hTheme : HTHEME -> "sptr"
; hdc : HDC optional -> "sptr"
; iPartId : INT -> "sptr"
; iStateId : INT -> "sptr"
; prc : RECT* optional -> "sptr"
; eSize : THEMESIZE -> "sptr"
; psz : SIZE* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "UXTHEME.dll" #cfunc global GetThemePartSize "GetThemePartSize" sptr, sptr, int, int, var, int, var ; res = GetThemePartSize(hTheme, hdc, iPartId, iStateId, prc, eSize, psz) ; hTheme : HTHEME -> "sptr" ; hdc : HDC optional -> "sptr" ; iPartId : INT -> "int" ; iStateId : INT -> "int" ; prc : RECT* optional -> "var" ; eSize : THEMESIZE -> "int" ; psz : SIZE* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "UXTHEME.dll" #cfunc global GetThemePartSize "GetThemePartSize" sptr, sptr, int, int, sptr, int, sptr ; res = GetThemePartSize(hTheme, hdc, iPartId, iStateId, varptr(prc), eSize, varptr(psz)) ; hTheme : HTHEME -> "sptr" ; hdc : HDC optional -> "sptr" ; iPartId : INT -> "int" ; iStateId : INT -> "int" ; prc : RECT* optional -> "sptr" ; eSize : THEMESIZE -> "int" ; psz : SIZE* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT GetThemePartSize(HTHEME hTheme, HDC hdc, INT iPartId, INT iStateId, RECT* prc, THEMESIZE eSize, SIZE* psz) #uselib "UXTHEME.dll" #cfunc global GetThemePartSize "GetThemePartSize" intptr, intptr, int, int, var, int, var ; res = GetThemePartSize(hTheme, hdc, iPartId, iStateId, prc, eSize, psz) ; hTheme : HTHEME -> "intptr" ; hdc : HDC optional -> "intptr" ; iPartId : INT -> "int" ; iStateId : INT -> "int" ; prc : RECT* optional -> "var" ; eSize : THEMESIZE -> "int" ; psz : SIZE* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT GetThemePartSize(HTHEME hTheme, HDC hdc, INT iPartId, INT iStateId, RECT* prc, THEMESIZE eSize, SIZE* psz) #uselib "UXTHEME.dll" #cfunc global GetThemePartSize "GetThemePartSize" intptr, intptr, int, int, intptr, int, intptr ; res = GetThemePartSize(hTheme, hdc, iPartId, iStateId, varptr(prc), eSize, varptr(psz)) ; hTheme : HTHEME -> "intptr" ; hdc : HDC optional -> "intptr" ; iPartId : INT -> "int" ; iStateId : INT -> "int" ; prc : RECT* optional -> "intptr" ; eSize : THEMESIZE -> "int" ; psz : SIZE* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
uxtheme = windows.NewLazySystemDLL("UXTHEME.dll")
procGetThemePartSize = uxtheme.NewProc("GetThemePartSize")
)
// hTheme (HTHEME), hdc (HDC optional), iPartId (INT), iStateId (INT), prc (RECT* optional), eSize (THEMESIZE), psz (SIZE* out)
r1, _, err := procGetThemePartSize.Call(
uintptr(hTheme),
uintptr(hdc),
uintptr(iPartId),
uintptr(iStateId),
uintptr(prc),
uintptr(eSize),
uintptr(psz),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction GetThemePartSize(
hTheme: NativeInt; // HTHEME
hdc: THandle; // HDC optional
iPartId: Integer; // INT
iStateId: Integer; // INT
prc: Pointer; // RECT* optional
eSize: Integer; // THEMESIZE
psz: Pointer // SIZE* out
): Integer; stdcall;
external 'UXTHEME.dll' name 'GetThemePartSize';result := DllCall("UXTHEME\GetThemePartSize"
, "Ptr", hTheme ; HTHEME
, "Ptr", hdc ; HDC optional
, "Int", iPartId ; INT
, "Int", iStateId ; INT
, "Ptr", prc ; RECT* optional
, "Int", eSize ; THEMESIZE
, "Ptr", psz ; SIZE* out
, "Int") ; return: HRESULT●GetThemePartSize(hTheme, hdc, iPartId, iStateId, prc, eSize, psz) = DLL("UXTHEME.dll", "int GetThemePartSize(int, void*, int, int, void*, int, void*)")
# 呼び出し: GetThemePartSize(hTheme, hdc, iPartId, iStateId, prc, eSize, psz)
# hTheme : HTHEME -> "int"
# hdc : HDC optional -> "void*"
# iPartId : INT -> "int"
# iStateId : INT -> "int"
# prc : RECT* optional -> "void*"
# eSize : THEMESIZE -> "int"
# psz : SIZE* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "uxtheme" fn GetThemePartSize(
hTheme: isize, // HTHEME
hdc: ?*anyopaque, // HDC optional
iPartId: i32, // INT
iStateId: i32, // INT
prc: [*c]RECT, // RECT* optional
eSize: i32, // THEMESIZE
psz: [*c]SIZE // SIZE* out
) callconv(std.os.windows.WINAPI) i32;proc GetThemePartSize(
hTheme: int, # HTHEME
hdc: pointer, # HDC optional
iPartId: int32, # INT
iStateId: int32, # INT
prc: ptr RECT, # RECT* optional
eSize: int32, # THEMESIZE
psz: ptr SIZE # SIZE* out
): int32 {.importc: "GetThemePartSize", stdcall, dynlib: "UXTHEME.dll".}pragma(lib, "uxtheme");
extern(Windows)
int GetThemePartSize(
ptrdiff_t hTheme, // HTHEME
void* hdc, // HDC optional
int iPartId, // INT
int iStateId, // INT
RECT* prc, // RECT* optional
int eSize, // THEMESIZE
SIZE* psz // SIZE* out
);ccall((:GetThemePartSize, "UXTHEME.dll"), stdcall, Int32,
(Int, Ptr{Cvoid}, Int32, Int32, Ptr{RECT}, Int32, Ptr{SIZE}),
hTheme, hdc, iPartId, iStateId, prc, eSize, psz)
# hTheme : HTHEME -> Int
# hdc : HDC optional -> Ptr{Cvoid}
# iPartId : INT -> Int32
# iStateId : INT -> Int32
# prc : RECT* optional -> Ptr{RECT}
# eSize : THEMESIZE -> Int32
# psz : SIZE* out -> Ptr{SIZE}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t GetThemePartSize(
intptr_t hTheme,
void* hdc,
int32_t iPartId,
int32_t iStateId,
void* prc,
int32_t eSize,
void* psz);
]]
local uxtheme = ffi.load("uxtheme")
-- uxtheme.GetThemePartSize(hTheme, hdc, iPartId, iStateId, prc, eSize, psz)
-- hTheme : HTHEME
-- hdc : HDC optional
-- iPartId : INT
-- iStateId : INT
-- prc : RECT* optional
-- eSize : THEMESIZE
-- psz : SIZE* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('UXTHEME.dll');
const GetThemePartSize = lib.func('__stdcall', 'GetThemePartSize', 'int32_t', ['intptr_t', 'void *', 'int32_t', 'int32_t', 'void *', 'int32_t', 'void *']);
// GetThemePartSize(hTheme, hdc, iPartId, iStateId, prc, eSize, psz)
// hTheme : HTHEME -> 'intptr_t'
// hdc : HDC optional -> 'void *'
// iPartId : INT -> 'int32_t'
// iStateId : INT -> 'int32_t'
// prc : RECT* optional -> 'void *'
// eSize : THEMESIZE -> 'int32_t'
// psz : SIZE* out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("UXTHEME.dll", {
GetThemePartSize: { parameters: ["isize", "pointer", "i32", "i32", "pointer", "i32", "pointer"], result: "i32" },
});
// lib.symbols.GetThemePartSize(hTheme, hdc, iPartId, iStateId, prc, eSize, psz)
// hTheme : HTHEME -> "isize"
// hdc : HDC optional -> "pointer"
// iPartId : INT -> "i32"
// iStateId : INT -> "i32"
// prc : RECT* optional -> "pointer"
// eSize : THEMESIZE -> "i32"
// psz : SIZE* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t GetThemePartSize(
intptr_t hTheme,
void* hdc,
int32_t iPartId,
int32_t iStateId,
void* prc,
int32_t eSize,
void* psz);
C, "UXTHEME.dll");
// $ffi->GetThemePartSize(hTheme, hdc, iPartId, iStateId, prc, eSize, psz);
// hTheme : HTHEME
// hdc : HDC optional
// iPartId : INT
// iStateId : INT
// prc : RECT* optional
// eSize : THEMESIZE
// psz : SIZE* out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Uxtheme extends StdCallLibrary {
Uxtheme INSTANCE = Native.load("uxtheme", Uxtheme.class);
int GetThemePartSize(
long hTheme, // HTHEME
Pointer hdc, // HDC optional
int iPartId, // INT
int iStateId, // INT
Pointer prc, // RECT* optional
int eSize, // THEMESIZE
Pointer psz // SIZE* out
);
}@[Link("uxtheme")]
lib LibUXTHEME
fun GetThemePartSize = GetThemePartSize(
hTheme : LibC::SSizeT, # HTHEME
hdc : Void*, # HDC optional
iPartId : Int32, # INT
iStateId : Int32, # INT
prc : RECT*, # RECT* optional
eSize : Int32, # THEMESIZE
psz : SIZE* # SIZE* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef GetThemePartSizeNative = Int32 Function(IntPtr, Pointer<Void>, Int32, Int32, Pointer<Void>, Int32, Pointer<Void>);
typedef GetThemePartSizeDart = int Function(int, Pointer<Void>, int, int, Pointer<Void>, int, Pointer<Void>);
final GetThemePartSize = DynamicLibrary.open('UXTHEME.dll')
.lookupFunction<GetThemePartSizeNative, GetThemePartSizeDart>('GetThemePartSize');
// hTheme : HTHEME -> IntPtr
// hdc : HDC optional -> Pointer<Void>
// iPartId : INT -> Int32
// iStateId : INT -> Int32
// prc : RECT* optional -> Pointer<Void>
// eSize : THEMESIZE -> Int32
// psz : SIZE* out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function GetThemePartSize(
hTheme: NativeInt; // HTHEME
hdc: THandle; // HDC optional
iPartId: Integer; // INT
iStateId: Integer; // INT
prc: Pointer; // RECT* optional
eSize: Integer; // THEMESIZE
psz: Pointer // SIZE* out
): Integer; stdcall;
external 'UXTHEME.dll' name 'GetThemePartSize';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GetThemePartSize"
c_GetThemePartSize :: CIntPtr -> Ptr () -> Int32 -> Int32 -> Ptr () -> Int32 -> Ptr () -> IO Int32
-- hTheme : HTHEME -> CIntPtr
-- hdc : HDC optional -> Ptr ()
-- iPartId : INT -> Int32
-- iStateId : INT -> Int32
-- prc : RECT* optional -> Ptr ()
-- eSize : THEMESIZE -> Int32
-- psz : SIZE* out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let getthemepartsize =
foreign "GetThemePartSize"
(intptr_t @-> (ptr void) @-> int32_t @-> int32_t @-> (ptr void) @-> int32_t @-> (ptr void) @-> returning int32_t)
(* hTheme : HTHEME -> intptr_t *)
(* hdc : HDC optional -> (ptr void) *)
(* iPartId : INT -> int32_t *)
(* iStateId : INT -> int32_t *)
(* prc : RECT* optional -> (ptr void) *)
(* eSize : THEMESIZE -> int32_t *)
(* psz : SIZE* out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library uxtheme (t "UXTHEME.dll"))
(cffi:use-foreign-library uxtheme)
(cffi:defcfun ("GetThemePartSize" get-theme-part-size :convention :stdcall) :int32
(h-theme :int64) ; HTHEME
(hdc :pointer) ; HDC optional
(i-part-id :int32) ; INT
(i-state-id :int32) ; INT
(prc :pointer) ; RECT* optional
(e-size :int32) ; THEMESIZE
(psz :pointer)) ; SIZE* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $GetThemePartSize = Win32::API::More->new('UXTHEME',
'int GetThemePartSize(LPARAM hTheme, HANDLE hdc, int iPartId, int iStateId, LPVOID prc, int eSize, LPVOID psz)');
# my $ret = $GetThemePartSize->Call($hTheme, $hdc, $iPartId, $iStateId, $prc, $eSize, $psz);
# hTheme : HTHEME -> LPARAM
# hdc : HDC optional -> HANDLE
# iPartId : INT -> int
# iStateId : INT -> int
# prc : RECT* optional -> LPVOID
# eSize : THEMESIZE -> int
# psz : SIZE* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。