ホーム › UI.Controls › SetWindowThemeAttribute
SetWindowThemeAttribute
関数ウィンドウのテーマ属性(非クライアント領域などの挙動)を設定する。
シグネチャ
// UXTHEME.dll
#include <windows.h>
HRESULT SetWindowThemeAttribute(
HWND hwnd,
WINDOWTHEMEATTRIBUTETYPE eAttribute,
void* pvAttribute,
DWORD cbAttribute
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hwnd | HWND | in |
| eAttribute | WINDOWTHEMEATTRIBUTETYPE | in |
| pvAttribute | void* | in |
| cbAttribute | DWORD | in |
戻り値の型: HRESULT
各言語での呼び出し定義
// UXTHEME.dll
#include <windows.h>
HRESULT SetWindowThemeAttribute(
HWND hwnd,
WINDOWTHEMEATTRIBUTETYPE eAttribute,
void* pvAttribute,
DWORD cbAttribute
);[DllImport("UXTHEME.dll", ExactSpelling = true)]
static extern int SetWindowThemeAttribute(
IntPtr hwnd, // HWND
int eAttribute, // WINDOWTHEMEATTRIBUTETYPE
IntPtr pvAttribute, // void*
uint cbAttribute // DWORD
);<DllImport("UXTHEME.dll", ExactSpelling:=True)>
Public Shared Function SetWindowThemeAttribute(
hwnd As IntPtr, ' HWND
eAttribute As Integer, ' WINDOWTHEMEATTRIBUTETYPE
pvAttribute As IntPtr, ' void*
cbAttribute As UInteger ' DWORD
) As Integer
End Function' hwnd : HWND
' eAttribute : WINDOWTHEMEATTRIBUTETYPE
' pvAttribute : void*
' cbAttribute : DWORD
Declare PtrSafe Function SetWindowThemeAttribute Lib "uxtheme" ( _
ByVal hwnd As LongPtr, _
ByVal eAttribute As Long, _
ByVal pvAttribute As LongPtr, _
ByVal cbAttribute As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SetWindowThemeAttribute = ctypes.windll.uxtheme.SetWindowThemeAttribute
SetWindowThemeAttribute.restype = ctypes.c_int
SetWindowThemeAttribute.argtypes = [
wintypes.HANDLE, # hwnd : HWND
ctypes.c_int, # eAttribute : WINDOWTHEMEATTRIBUTETYPE
ctypes.POINTER(None), # pvAttribute : void*
wintypes.DWORD, # cbAttribute : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('UXTHEME.dll')
SetWindowThemeAttribute = Fiddle::Function.new(
lib['SetWindowThemeAttribute'],
[
Fiddle::TYPE_VOIDP, # hwnd : HWND
Fiddle::TYPE_INT, # eAttribute : WINDOWTHEMEATTRIBUTETYPE
Fiddle::TYPE_VOIDP, # pvAttribute : void*
-Fiddle::TYPE_INT, # cbAttribute : DWORD
],
Fiddle::TYPE_INT)#[link(name = "uxtheme")]
extern "system" {
fn SetWindowThemeAttribute(
hwnd: *mut core::ffi::c_void, // HWND
eAttribute: i32, // WINDOWTHEMEATTRIBUTETYPE
pvAttribute: *mut (), // void*
cbAttribute: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("UXTHEME.dll")]
public static extern int SetWindowThemeAttribute(IntPtr hwnd, int eAttribute, IntPtr pvAttribute, uint cbAttribute);
"@
$api = Add-Type -MemberDefinition $sig -Name 'UXTHEME_SetWindowThemeAttribute' -Namespace Win32 -PassThru
# $api::SetWindowThemeAttribute(hwnd, eAttribute, pvAttribute, cbAttribute)#uselib "UXTHEME.dll"
#func global SetWindowThemeAttribute "SetWindowThemeAttribute" sptr, sptr, sptr, sptr
; SetWindowThemeAttribute hwnd, eAttribute, pvAttribute, cbAttribute ; 戻り値は stat
; hwnd : HWND -> "sptr"
; eAttribute : WINDOWTHEMEATTRIBUTETYPE -> "sptr"
; pvAttribute : void* -> "sptr"
; cbAttribute : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "UXTHEME.dll"
#cfunc global SetWindowThemeAttribute "SetWindowThemeAttribute" sptr, int, sptr, int
; res = SetWindowThemeAttribute(hwnd, eAttribute, pvAttribute, cbAttribute)
; hwnd : HWND -> "sptr"
; eAttribute : WINDOWTHEMEATTRIBUTETYPE -> "int"
; pvAttribute : void* -> "sptr"
; cbAttribute : DWORD -> "int"; HRESULT SetWindowThemeAttribute(HWND hwnd, WINDOWTHEMEATTRIBUTETYPE eAttribute, void* pvAttribute, DWORD cbAttribute)
#uselib "UXTHEME.dll"
#cfunc global SetWindowThemeAttribute "SetWindowThemeAttribute" intptr, int, intptr, int
; res = SetWindowThemeAttribute(hwnd, eAttribute, pvAttribute, cbAttribute)
; hwnd : HWND -> "intptr"
; eAttribute : WINDOWTHEMEATTRIBUTETYPE -> "int"
; pvAttribute : void* -> "intptr"
; cbAttribute : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
uxtheme = windows.NewLazySystemDLL("UXTHEME.dll")
procSetWindowThemeAttribute = uxtheme.NewProc("SetWindowThemeAttribute")
)
// hwnd (HWND), eAttribute (WINDOWTHEMEATTRIBUTETYPE), pvAttribute (void*), cbAttribute (DWORD)
r1, _, err := procSetWindowThemeAttribute.Call(
uintptr(hwnd),
uintptr(eAttribute),
uintptr(pvAttribute),
uintptr(cbAttribute),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction SetWindowThemeAttribute(
hwnd: THandle; // HWND
eAttribute: Integer; // WINDOWTHEMEATTRIBUTETYPE
pvAttribute: Pointer; // void*
cbAttribute: DWORD // DWORD
): Integer; stdcall;
external 'UXTHEME.dll' name 'SetWindowThemeAttribute';result := DllCall("UXTHEME\SetWindowThemeAttribute"
, "Ptr", hwnd ; HWND
, "Int", eAttribute ; WINDOWTHEMEATTRIBUTETYPE
, "Ptr", pvAttribute ; void*
, "UInt", cbAttribute ; DWORD
, "Int") ; return: HRESULT●SetWindowThemeAttribute(hwnd, eAttribute, pvAttribute, cbAttribute) = DLL("UXTHEME.dll", "int SetWindowThemeAttribute(void*, int, void*, dword)")
# 呼び出し: SetWindowThemeAttribute(hwnd, eAttribute, pvAttribute, cbAttribute)
# hwnd : HWND -> "void*"
# eAttribute : WINDOWTHEMEATTRIBUTETYPE -> "int"
# pvAttribute : void* -> "void*"
# cbAttribute : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。