ホーム › UI.Controls › GetThemeSysColorBrush
GetThemeSysColorBrush
関数テーマのシステム色に対応するブラシを取得する。
シグネチャ
// UXTHEME.dll
#include <windows.h>
HBRUSH GetThemeSysColorBrush(
HTHEME hTheme, // optional
INT iColorId
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hTheme | HTHEME | inoptional | テーマデータへのハンドル。 |
| iColorId | INT | in | 目的のシステムカラーの番号を指定する int 型の値。次のいずれかの値を指定できます。 |
戻り値の型: HBRUSH
公式ドキュメント
システムカラーのブラシを取得します。
戻り値
型: HBRUSH
ブラシデータへのハンドル。
解説(Remarks)
テーマデータハンドルが NULL ハンドルでない場合、GetThemeSysColorBrush は、ビジュアルスタイルの SysMetrics セクションから指定された色に一致するブラシを返します。テーマデータハンドルが NULL の場合、この関数はグローバルなシステムカラーに一致するブラシを返します。
この関数によって返されるブラシハンドルは、不要になったときに DeleteObject を使用して解放する必要があります。
出典・ライセンス: 上記「公式ドキュメント」の内容は 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>
HBRUSH GetThemeSysColorBrush(
HTHEME hTheme, // optional
INT iColorId
);[DllImport("UXTHEME.dll", ExactSpelling = true)]
static extern IntPtr GetThemeSysColorBrush(
IntPtr hTheme, // HTHEME optional
int iColorId // INT
);<DllImport("UXTHEME.dll", ExactSpelling:=True)>
Public Shared Function GetThemeSysColorBrush(
hTheme As IntPtr, ' HTHEME optional
iColorId As Integer ' INT
) As IntPtr
End Function' hTheme : HTHEME optional
' iColorId : INT
Declare PtrSafe Function GetThemeSysColorBrush Lib "uxtheme" ( _
ByVal hTheme As LongPtr, _
ByVal iColorId As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetThemeSysColorBrush = ctypes.windll.uxtheme.GetThemeSysColorBrush
GetThemeSysColorBrush.restype = ctypes.c_void_p
GetThemeSysColorBrush.argtypes = [
ctypes.c_ssize_t, # hTheme : HTHEME optional
ctypes.c_int, # iColorId : INT
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('UXTHEME.dll')
GetThemeSysColorBrush = Fiddle::Function.new(
lib['GetThemeSysColorBrush'],
[
Fiddle::TYPE_INTPTR_T, # hTheme : HTHEME optional
Fiddle::TYPE_INT, # iColorId : INT
],
Fiddle::TYPE_VOIDP)#[link(name = "uxtheme")]
extern "system" {
fn GetThemeSysColorBrush(
hTheme: isize, // HTHEME optional
iColorId: i32 // INT
) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("UXTHEME.dll")]
public static extern IntPtr GetThemeSysColorBrush(IntPtr hTheme, int iColorId);
"@
$api = Add-Type -MemberDefinition $sig -Name 'UXTHEME_GetThemeSysColorBrush' -Namespace Win32 -PassThru
# $api::GetThemeSysColorBrush(hTheme, iColorId)#uselib "UXTHEME.dll"
#func global GetThemeSysColorBrush "GetThemeSysColorBrush" sptr, sptr
; GetThemeSysColorBrush hTheme, iColorId ; 戻り値は stat
; hTheme : HTHEME optional -> "sptr"
; iColorId : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "UXTHEME.dll"
#cfunc global GetThemeSysColorBrush "GetThemeSysColorBrush" sptr, int
; res = GetThemeSysColorBrush(hTheme, iColorId)
; hTheme : HTHEME optional -> "sptr"
; iColorId : INT -> "int"; HBRUSH GetThemeSysColorBrush(HTHEME hTheme, INT iColorId)
#uselib "UXTHEME.dll"
#cfunc global GetThemeSysColorBrush "GetThemeSysColorBrush" intptr, int
; res = GetThemeSysColorBrush(hTheme, iColorId)
; hTheme : HTHEME optional -> "intptr"
; iColorId : INT -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
uxtheme = windows.NewLazySystemDLL("UXTHEME.dll")
procGetThemeSysColorBrush = uxtheme.NewProc("GetThemeSysColorBrush")
)
// hTheme (HTHEME optional), iColorId (INT)
r1, _, err := procGetThemeSysColorBrush.Call(
uintptr(hTheme),
uintptr(iColorId),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HBRUSHfunction GetThemeSysColorBrush(
hTheme: NativeInt; // HTHEME optional
iColorId: Integer // INT
): THandle; stdcall;
external 'UXTHEME.dll' name 'GetThemeSysColorBrush';result := DllCall("UXTHEME\GetThemeSysColorBrush"
, "Ptr", hTheme ; HTHEME optional
, "Int", iColorId ; INT
, "Ptr") ; return: HBRUSH●GetThemeSysColorBrush(hTheme, iColorId) = DLL("UXTHEME.dll", "void* GetThemeSysColorBrush(int, int)")
# 呼び出し: GetThemeSysColorBrush(hTheme, iColorId)
# hTheme : HTHEME optional -> "int"
# iColorId : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "uxtheme" fn GetThemeSysColorBrush(
hTheme: isize, // HTHEME optional
iColorId: i32 // INT
) callconv(std.os.windows.WINAPI) ?*anyopaque;proc GetThemeSysColorBrush(
hTheme: int, # HTHEME optional
iColorId: int32 # INT
): pointer {.importc: "GetThemeSysColorBrush", stdcall, dynlib: "UXTHEME.dll".}pragma(lib, "uxtheme");
extern(Windows)
void* GetThemeSysColorBrush(
ptrdiff_t hTheme, // HTHEME optional
int iColorId // INT
);ccall((:GetThemeSysColorBrush, "UXTHEME.dll"), stdcall, Ptr{Cvoid},
(Int, Int32),
hTheme, iColorId)
# hTheme : HTHEME optional -> Int
# iColorId : INT -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
void* GetThemeSysColorBrush(
intptr_t hTheme,
int32_t iColorId);
]]
local uxtheme = ffi.load("uxtheme")
-- uxtheme.GetThemeSysColorBrush(hTheme, iColorId)
-- hTheme : HTHEME optional
-- iColorId : INT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('UXTHEME.dll');
const GetThemeSysColorBrush = lib.func('__stdcall', 'GetThemeSysColorBrush', 'void *', ['intptr_t', 'int32_t']);
// GetThemeSysColorBrush(hTheme, iColorId)
// hTheme : HTHEME optional -> 'intptr_t'
// iColorId : INT -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("UXTHEME.dll", {
GetThemeSysColorBrush: { parameters: ["isize", "i32"], result: "pointer" },
});
// lib.symbols.GetThemeSysColorBrush(hTheme, iColorId)
// hTheme : HTHEME optional -> "isize"
// iColorId : INT -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
void* GetThemeSysColorBrush(
intptr_t hTheme,
int32_t iColorId);
C, "UXTHEME.dll");
// $ffi->GetThemeSysColorBrush(hTheme, iColorId);
// hTheme : HTHEME optional
// iColorId : 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);
Pointer GetThemeSysColorBrush(
long hTheme, // HTHEME optional
int iColorId // INT
);
}@[Link("uxtheme")]
lib LibUXTHEME
fun GetThemeSysColorBrush = GetThemeSysColorBrush(
hTheme : LibC::SSizeT, # HTHEME optional
iColorId : Int32 # INT
) : Void*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef GetThemeSysColorBrushNative = Pointer<Void> Function(IntPtr, Int32);
typedef GetThemeSysColorBrushDart = Pointer<Void> Function(int, int);
final GetThemeSysColorBrush = DynamicLibrary.open('UXTHEME.dll')
.lookupFunction<GetThemeSysColorBrushNative, GetThemeSysColorBrushDart>('GetThemeSysColorBrush');
// hTheme : HTHEME optional -> IntPtr
// iColorId : INT -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function GetThemeSysColorBrush(
hTheme: NativeInt; // HTHEME optional
iColorId: Integer // INT
): THandle; stdcall;
external 'UXTHEME.dll' name 'GetThemeSysColorBrush';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GetThemeSysColorBrush"
c_GetThemeSysColorBrush :: CIntPtr -> Int32 -> IO (Ptr ())
-- hTheme : HTHEME optional -> CIntPtr
-- iColorId : INT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let getthemesyscolorbrush =
foreign "GetThemeSysColorBrush"
(intptr_t @-> int32_t @-> returning (ptr void))
(* hTheme : HTHEME optional -> intptr_t *)
(* iColorId : 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 ("GetThemeSysColorBrush" get-theme-sys-color-brush :convention :stdcall) :pointer
(h-theme :int64) ; HTHEME optional
(i-color-id :int32)) ; INT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $GetThemeSysColorBrush = Win32::API::More->new('UXTHEME',
'HANDLE GetThemeSysColorBrush(LPARAM hTheme, int iColorId)');
# my $ret = $GetThemeSysColorBrush->Call($hTheme, $iColorId);
# hTheme : HTHEME optional -> LPARAM
# iColorId : INT -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。