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

GetThemeSysSize

関数
テーマで定義されたシステムサイズ値を取得する。
DLLUXTHEME.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

INT GetThemeSysSize(
    HTHEME hTheme,   // optional
    INT iSizeId
);

パラメーター

名前方向説明
hThemeHTHEMEinoptionalテーマデータへのハンドル。
iSizeIdINTin

取得するシステムサイズメトリックを指定する int 型の値。次の値が有効です。

意味
SM_CXBORDER
境界線の幅を指定します。
SM_CXVSCROLL
スクロールバーの幅を指定します。
SM_CXHSCROLL
スクロールバーの高さを指定します。
SM_CXSIZE
キャプションの幅を指定します。
SM_CYSIZE
キャプションの高さを指定します。
SM_CXSMSIZE
小さいキャプションの幅を指定します。
SM_CYSMSIZE
小さいキャプションの高さを指定します。
SM_CXMENUSIZE
メニューバーの幅を指定します。
SM_CYMENUSIZE
メニューバーの高さを指定します。
SM_CXPADDEDBORDER
キャプション付きウィンドウの境界線パディングの量を指定します。

戻り値の型: INT

公式ドキュメント

テーマデータからシステムサイズメトリックの値を取得します。

戻り値

型: int

サイズをピクセル単位で返します。

解説(Remarks)

hThemeNULLない場合、この関数は現在のビジュアルスタイル(ビジュアルスタイルの SysMetrics セクション)に格納されているサイズを、現在の画面 dpi に合わせてスケーリングして返します。hThemeNULL の場合、この関数はグローバルなシステムメトリックをピクセル単位で返しますが、現在の dpi に合わせてスケーリングされるのはアプリケーションが dpi 対応としてマークされている場合のみです。それ以外の場合、返されるピクセルはスケーリングされません。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

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

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

GetThemeSysSize = ctypes.windll.uxtheme.GetThemeSysSize
GetThemeSysSize.restype = ctypes.c_int
GetThemeSysSize.argtypes = [
    ctypes.c_ssize_t,  # hTheme : HTHEME optional
    ctypes.c_int,  # iSizeId : INT
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('UXTHEME.dll')
GetThemeSysSize = Fiddle::Function.new(
  lib['GetThemeSysSize'],
  [
    Fiddle::TYPE_INTPTR_T,  # hTheme : HTHEME optional
    Fiddle::TYPE_INT,  # iSizeId : INT
  ],
  Fiddle::TYPE_INT)
#[link(name = "uxtheme")]
extern "system" {
    fn GetThemeSysSize(
        hTheme: isize,  // HTHEME optional
        iSizeId: i32  // INT
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("UXTHEME.dll")]
public static extern int GetThemeSysSize(IntPtr hTheme, int iSizeId);
"@
$api = Add-Type -MemberDefinition $sig -Name 'UXTHEME_GetThemeSysSize' -Namespace Win32 -PassThru
# $api::GetThemeSysSize(hTheme, iSizeId)
#uselib "UXTHEME.dll"
#func global GetThemeSysSize "GetThemeSysSize" sptr, sptr
; GetThemeSysSize hTheme, iSizeId   ; 戻り値は stat
; hTheme : HTHEME optional -> "sptr"
; iSizeId : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "UXTHEME.dll"
#cfunc global GetThemeSysSize "GetThemeSysSize" sptr, int
; res = GetThemeSysSize(hTheme, iSizeId)
; hTheme : HTHEME optional -> "sptr"
; iSizeId : INT -> "int"
; INT GetThemeSysSize(HTHEME hTheme, INT iSizeId)
#uselib "UXTHEME.dll"
#cfunc global GetThemeSysSize "GetThemeSysSize" intptr, int
; res = GetThemeSysSize(hTheme, iSizeId)
; hTheme : HTHEME optional -> "intptr"
; iSizeId : INT -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	uxtheme = windows.NewLazySystemDLL("UXTHEME.dll")
	procGetThemeSysSize = uxtheme.NewProc("GetThemeSysSize")
)

// hTheme (HTHEME optional), iSizeId (INT)
r1, _, err := procGetThemeSysSize.Call(
	uintptr(hTheme),
	uintptr(iSizeId),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function GetThemeSysSize(
  hTheme: NativeInt;   // HTHEME optional
  iSizeId: Integer   // INT
): Integer; stdcall;
  external 'UXTHEME.dll' name 'GetThemeSysSize';
result := DllCall("UXTHEME\GetThemeSysSize"
    , "Ptr", hTheme   ; HTHEME optional
    , "Int", iSizeId   ; INT
    , "Int")   ; return: INT
●GetThemeSysSize(hTheme, iSizeId) = DLL("UXTHEME.dll", "int GetThemeSysSize(int, int)")
# 呼び出し: GetThemeSysSize(hTheme, iSizeId)
# hTheme : HTHEME optional -> "int"
# iSizeId : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "uxtheme" fn GetThemeSysSize(
    hTheme: isize, // HTHEME optional
    iSizeId: i32 // INT
) callconv(std.os.windows.WINAPI) i32;
proc GetThemeSysSize(
    hTheme: int,  # HTHEME optional
    iSizeId: int32  # INT
): int32 {.importc: "GetThemeSysSize", stdcall, dynlib: "UXTHEME.dll".}
pragma(lib, "uxtheme");
extern(Windows)
int GetThemeSysSize(
    ptrdiff_t hTheme,   // HTHEME optional
    int iSizeId   // INT
);
ccall((:GetThemeSysSize, "UXTHEME.dll"), stdcall, Int32,
      (Int, Int32),
      hTheme, iSizeId)
# hTheme : HTHEME optional -> Int
# iSizeId : INT -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t GetThemeSysSize(
    intptr_t hTheme,
    int32_t iSizeId);
]]
local uxtheme = ffi.load("uxtheme")
-- uxtheme.GetThemeSysSize(hTheme, iSizeId)
-- hTheme : HTHEME optional
-- iSizeId : INT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('UXTHEME.dll');
const GetThemeSysSize = lib.func('__stdcall', 'GetThemeSysSize', 'int32_t', ['intptr_t', 'int32_t']);
// GetThemeSysSize(hTheme, iSizeId)
// hTheme : HTHEME optional -> 'intptr_t'
// iSizeId : INT -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("UXTHEME.dll", {
  GetThemeSysSize: { parameters: ["isize", "i32"], result: "i32" },
});
// lib.symbols.GetThemeSysSize(hTheme, iSizeId)
// hTheme : HTHEME optional -> "isize"
// iSizeId : INT -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t GetThemeSysSize(
    intptr_t hTheme,
    int32_t iSizeId);
C, "UXTHEME.dll");
// $ffi->GetThemeSysSize(hTheme, iSizeId);
// hTheme : HTHEME optional
// iSizeId : INT
// 構造体/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 GetThemeSysSize(
        long hTheme,   // HTHEME optional
        int iSizeId   // INT
    );
}
@[Link("uxtheme")]
lib LibUXTHEME
  fun GetThemeSysSize = GetThemeSysSize(
    hTheme : LibC::SSizeT,   # HTHEME optional
    iSizeId : Int32   # INT
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef GetThemeSysSizeNative = Int32 Function(IntPtr, Int32);
typedef GetThemeSysSizeDart = int Function(int, int);
final GetThemeSysSize = DynamicLibrary.open('UXTHEME.dll')
    .lookupFunction<GetThemeSysSizeNative, GetThemeSysSizeDart>('GetThemeSysSize');
// hTheme : HTHEME optional -> IntPtr
// iSizeId : INT -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function GetThemeSysSize(
  hTheme: NativeInt;   // HTHEME optional
  iSizeId: Integer   // INT
): Integer; stdcall;
  external 'UXTHEME.dll' name 'GetThemeSysSize';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "GetThemeSysSize"
  c_GetThemeSysSize :: CIntPtr -> Int32 -> IO Int32
-- hTheme : HTHEME optional -> CIntPtr
-- iSizeId : INT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let getthemesyssize =
  foreign "GetThemeSysSize"
    (intptr_t @-> int32_t @-> returning int32_t)
(* hTheme : HTHEME optional -> intptr_t *)
(* iSizeId : INT -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library uxtheme (t "UXTHEME.dll"))
(cffi:use-foreign-library uxtheme)

(cffi:defcfun ("GetThemeSysSize" get-theme-sys-size :convention :stdcall) :int32
  (h-theme :int64)   ; HTHEME optional
  (i-size-id :int32))   ; INT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $GetThemeSysSize = Win32::API::More->new('UXTHEME',
    'int GetThemeSysSize(LPARAM hTheme, int iSizeId)');
# my $ret = $GetThemeSysSize->Call($hTheme, $iSizeId);
# hTheme : HTHEME optional -> LPARAM
# iSizeId : INT -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。