ホーム › UI.Controls › GetThemeColor
GetThemeColor
関数指定プロパティのテーマ色(COLORREF)を取得する。
シグネチャ
// UXTHEME.dll
#include <windows.h>
HRESULT GetThemeColor(
HTHEME hTheme,
INT iPartId,
INT iStateId,
INT iPropId,
COLORREF* pColor
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hTheme | HTHEME | in | ウィンドウの指定されたテーマデータへのハンドル。HTHEME を作成するには OpenThemeData を使用します。 |
| iPartId | INT | in | 色プロパティを含むパーツを指定する int 型の値。Parts and States を参照してください。 |
| iStateId | INT | in | パーツの状態を指定する int 型の値。Parts and States を参照してください。 |
| iPropId | INT | in | 取得するプロパティを指定する int 型の値。指定可能な値の一覧については、Property Identifiers を参照してください。 |
| pColor | COLORREF* | out | 色の値を受け取る COLORREF 構造体へのポインター。 |
戻り値の型: 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 GetThemeColor(
HTHEME hTheme,
INT iPartId,
INT iStateId,
INT iPropId,
COLORREF* pColor
);[DllImport("UXTHEME.dll", ExactSpelling = true)]
static extern int GetThemeColor(
IntPtr hTheme, // HTHEME
int iPartId, // INT
int iStateId, // INT
int iPropId, // INT
out uint pColor // COLORREF* out
);<DllImport("UXTHEME.dll", ExactSpelling:=True)>
Public Shared Function GetThemeColor(
hTheme As IntPtr, ' HTHEME
iPartId As Integer, ' INT
iStateId As Integer, ' INT
iPropId As Integer, ' INT
<Out> ByRef pColor As UInteger ' COLORREF* out
) As Integer
End Function' hTheme : HTHEME
' iPartId : INT
' iStateId : INT
' iPropId : INT
' pColor : COLORREF* out
Declare PtrSafe Function GetThemeColor Lib "uxtheme" ( _
ByVal hTheme As LongPtr, _
ByVal iPartId As Long, _
ByVal iStateId As Long, _
ByVal iPropId As Long, _
ByRef pColor As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetThemeColor = ctypes.windll.uxtheme.GetThemeColor
GetThemeColor.restype = ctypes.c_int
GetThemeColor.argtypes = [
ctypes.c_ssize_t, # hTheme : HTHEME
ctypes.c_int, # iPartId : INT
ctypes.c_int, # iStateId : INT
ctypes.c_int, # iPropId : INT
ctypes.c_void_p, # pColor : COLORREF* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('UXTHEME.dll')
GetThemeColor = Fiddle::Function.new(
lib['GetThemeColor'],
[
Fiddle::TYPE_INTPTR_T, # hTheme : HTHEME
Fiddle::TYPE_INT, # iPartId : INT
Fiddle::TYPE_INT, # iStateId : INT
Fiddle::TYPE_INT, # iPropId : INT
Fiddle::TYPE_VOIDP, # pColor : COLORREF* out
],
Fiddle::TYPE_INT)#[link(name = "uxtheme")]
extern "system" {
fn GetThemeColor(
hTheme: isize, // HTHEME
iPartId: i32, // INT
iStateId: i32, // INT
iPropId: i32, // INT
pColor: *mut u32 // COLORREF* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("UXTHEME.dll")]
public static extern int GetThemeColor(IntPtr hTheme, int iPartId, int iStateId, int iPropId, out uint pColor);
"@
$api = Add-Type -MemberDefinition $sig -Name 'UXTHEME_GetThemeColor' -Namespace Win32 -PassThru
# $api::GetThemeColor(hTheme, iPartId, iStateId, iPropId, pColor)#uselib "UXTHEME.dll"
#func global GetThemeColor "GetThemeColor" sptr, sptr, sptr, sptr, sptr
; GetThemeColor hTheme, iPartId, iStateId, iPropId, varptr(pColor) ; 戻り値は stat
; hTheme : HTHEME -> "sptr"
; iPartId : INT -> "sptr"
; iStateId : INT -> "sptr"
; iPropId : INT -> "sptr"
; pColor : COLORREF* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "UXTHEME.dll" #cfunc global GetThemeColor "GetThemeColor" sptr, int, int, int, var ; res = GetThemeColor(hTheme, iPartId, iStateId, iPropId, pColor) ; hTheme : HTHEME -> "sptr" ; iPartId : INT -> "int" ; iStateId : INT -> "int" ; iPropId : INT -> "int" ; pColor : COLORREF* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "UXTHEME.dll" #cfunc global GetThemeColor "GetThemeColor" sptr, int, int, int, sptr ; res = GetThemeColor(hTheme, iPartId, iStateId, iPropId, varptr(pColor)) ; hTheme : HTHEME -> "sptr" ; iPartId : INT -> "int" ; iStateId : INT -> "int" ; iPropId : INT -> "int" ; pColor : COLORREF* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT GetThemeColor(HTHEME hTheme, INT iPartId, INT iStateId, INT iPropId, COLORREF* pColor) #uselib "UXTHEME.dll" #cfunc global GetThemeColor "GetThemeColor" intptr, int, int, int, var ; res = GetThemeColor(hTheme, iPartId, iStateId, iPropId, pColor) ; hTheme : HTHEME -> "intptr" ; iPartId : INT -> "int" ; iStateId : INT -> "int" ; iPropId : INT -> "int" ; pColor : COLORREF* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT GetThemeColor(HTHEME hTheme, INT iPartId, INT iStateId, INT iPropId, COLORREF* pColor) #uselib "UXTHEME.dll" #cfunc global GetThemeColor "GetThemeColor" intptr, int, int, int, intptr ; res = GetThemeColor(hTheme, iPartId, iStateId, iPropId, varptr(pColor)) ; hTheme : HTHEME -> "intptr" ; iPartId : INT -> "int" ; iStateId : INT -> "int" ; iPropId : INT -> "int" ; pColor : COLORREF* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
uxtheme = windows.NewLazySystemDLL("UXTHEME.dll")
procGetThemeColor = uxtheme.NewProc("GetThemeColor")
)
// hTheme (HTHEME), iPartId (INT), iStateId (INT), iPropId (INT), pColor (COLORREF* out)
r1, _, err := procGetThemeColor.Call(
uintptr(hTheme),
uintptr(iPartId),
uintptr(iStateId),
uintptr(iPropId),
uintptr(pColor),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction GetThemeColor(
hTheme: NativeInt; // HTHEME
iPartId: Integer; // INT
iStateId: Integer; // INT
iPropId: Integer; // INT
pColor: Pointer // COLORREF* out
): Integer; stdcall;
external 'UXTHEME.dll' name 'GetThemeColor';result := DllCall("UXTHEME\GetThemeColor"
, "Ptr", hTheme ; HTHEME
, "Int", iPartId ; INT
, "Int", iStateId ; INT
, "Int", iPropId ; INT
, "Ptr", pColor ; COLORREF* out
, "Int") ; return: HRESULT●GetThemeColor(hTheme, iPartId, iStateId, iPropId, pColor) = DLL("UXTHEME.dll", "int GetThemeColor(int, int, int, int, void*)")
# 呼び出し: GetThemeColor(hTheme, iPartId, iStateId, iPropId, pColor)
# hTheme : HTHEME -> "int"
# iPartId : INT -> "int"
# iStateId : INT -> "int"
# iPropId : INT -> "int"
# pColor : COLORREF* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "uxtheme" fn GetThemeColor(
hTheme: isize, // HTHEME
iPartId: i32, // INT
iStateId: i32, // INT
iPropId: i32, // INT
pColor: [*c]u32 // COLORREF* out
) callconv(std.os.windows.WINAPI) i32;proc GetThemeColor(
hTheme: int, # HTHEME
iPartId: int32, # INT
iStateId: int32, # INT
iPropId: int32, # INT
pColor: ptr uint32 # COLORREF* out
): int32 {.importc: "GetThemeColor", stdcall, dynlib: "UXTHEME.dll".}pragma(lib, "uxtheme");
extern(Windows)
int GetThemeColor(
ptrdiff_t hTheme, // HTHEME
int iPartId, // INT
int iStateId, // INT
int iPropId, // INT
uint* pColor // COLORREF* out
);ccall((:GetThemeColor, "UXTHEME.dll"), stdcall, Int32,
(Int, Int32, Int32, Int32, Ptr{UInt32}),
hTheme, iPartId, iStateId, iPropId, pColor)
# hTheme : HTHEME -> Int
# iPartId : INT -> Int32
# iStateId : INT -> Int32
# iPropId : INT -> Int32
# pColor : COLORREF* out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t GetThemeColor(
intptr_t hTheme,
int32_t iPartId,
int32_t iStateId,
int32_t iPropId,
uint32_t* pColor);
]]
local uxtheme = ffi.load("uxtheme")
-- uxtheme.GetThemeColor(hTheme, iPartId, iStateId, iPropId, pColor)
-- hTheme : HTHEME
-- iPartId : INT
-- iStateId : INT
-- iPropId : INT
-- pColor : COLORREF* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('UXTHEME.dll');
const GetThemeColor = lib.func('__stdcall', 'GetThemeColor', 'int32_t', ['intptr_t', 'int32_t', 'int32_t', 'int32_t', 'uint32_t *']);
// GetThemeColor(hTheme, iPartId, iStateId, iPropId, pColor)
// hTheme : HTHEME -> 'intptr_t'
// iPartId : INT -> 'int32_t'
// iStateId : INT -> 'int32_t'
// iPropId : INT -> 'int32_t'
// pColor : COLORREF* out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("UXTHEME.dll", {
GetThemeColor: { parameters: ["isize", "i32", "i32", "i32", "pointer"], result: "i32" },
});
// lib.symbols.GetThemeColor(hTheme, iPartId, iStateId, iPropId, pColor)
// hTheme : HTHEME -> "isize"
// iPartId : INT -> "i32"
// iStateId : INT -> "i32"
// iPropId : INT -> "i32"
// pColor : COLORREF* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t GetThemeColor(
intptr_t hTheme,
int32_t iPartId,
int32_t iStateId,
int32_t iPropId,
uint32_t* pColor);
C, "UXTHEME.dll");
// $ffi->GetThemeColor(hTheme, iPartId, iStateId, iPropId, pColor);
// hTheme : HTHEME
// iPartId : INT
// iStateId : INT
// iPropId : INT
// pColor : COLORREF* 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 GetThemeColor(
long hTheme, // HTHEME
int iPartId, // INT
int iStateId, // INT
int iPropId, // INT
IntByReference pColor // COLORREF* out
);
}@[Link("uxtheme")]
lib LibUXTHEME
fun GetThemeColor = GetThemeColor(
hTheme : LibC::SSizeT, # HTHEME
iPartId : Int32, # INT
iStateId : Int32, # INT
iPropId : Int32, # INT
pColor : UInt32* # COLORREF* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef GetThemeColorNative = Int32 Function(IntPtr, Int32, Int32, Int32, Pointer<Uint32>);
typedef GetThemeColorDart = int Function(int, int, int, int, Pointer<Uint32>);
final GetThemeColor = DynamicLibrary.open('UXTHEME.dll')
.lookupFunction<GetThemeColorNative, GetThemeColorDart>('GetThemeColor');
// hTheme : HTHEME -> IntPtr
// iPartId : INT -> Int32
// iStateId : INT -> Int32
// iPropId : INT -> Int32
// pColor : COLORREF* out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function GetThemeColor(
hTheme: NativeInt; // HTHEME
iPartId: Integer; // INT
iStateId: Integer; // INT
iPropId: Integer; // INT
pColor: Pointer // COLORREF* out
): Integer; stdcall;
external 'UXTHEME.dll' name 'GetThemeColor';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GetThemeColor"
c_GetThemeColor :: CIntPtr -> Int32 -> Int32 -> Int32 -> Ptr Word32 -> IO Int32
-- hTheme : HTHEME -> CIntPtr
-- iPartId : INT -> Int32
-- iStateId : INT -> Int32
-- iPropId : INT -> Int32
-- pColor : COLORREF* out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let getthemecolor =
foreign "GetThemeColor"
(intptr_t @-> int32_t @-> int32_t @-> int32_t @-> (ptr uint32_t) @-> returning int32_t)
(* hTheme : HTHEME -> intptr_t *)
(* iPartId : INT -> int32_t *)
(* iStateId : INT -> int32_t *)
(* iPropId : INT -> int32_t *)
(* pColor : COLORREF* out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library uxtheme (t "UXTHEME.dll"))
(cffi:use-foreign-library uxtheme)
(cffi:defcfun ("GetThemeColor" get-theme-color :convention :stdcall) :int32
(h-theme :int64) ; HTHEME
(i-part-id :int32) ; INT
(i-state-id :int32) ; INT
(i-prop-id :int32) ; INT
(p-color :pointer)) ; COLORREF* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $GetThemeColor = Win32::API::More->new('UXTHEME',
'int GetThemeColor(LPARAM hTheme, int iPartId, int iStateId, int iPropId, LPVOID pColor)');
# my $ret = $GetThemeColor->Call($hTheme, $iPartId, $iStateId, $iPropId, $pColor);
# hTheme : HTHEME -> LPARAM
# iPartId : INT -> int
# iStateId : INT -> int
# iPropId : INT -> int
# pColor : COLORREF* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。