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

GetThemeSysColor

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

シグネチャ

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

COLORREF GetThemeSysColor(
    HTHEME hTheme,   // optional
    INT iColorId
);

パラメーター

名前方向
hThemeHTHEMEinoptional
iColorIdINTin

戻り値の型: COLORREF

各言語での呼び出し定義

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

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

GetThemeSysColor = ctypes.windll.uxtheme.GetThemeSysColor
GetThemeSysColor.restype = wintypes.DWORD
GetThemeSysColor.argtypes = [
    ctypes.c_ssize_t,  # hTheme : HTHEME optional
    ctypes.c_int,  # iColorId : INT
]
require 'fiddle'
require 'fiddle/import'

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

var (
	uxtheme = windows.NewLazySystemDLL("UxTheme.dll")
	procGetThemeSysColor = uxtheme.NewProc("GetThemeSysColor")
)

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