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