Win32 API 日本語リファレンス
ホームGraphics.Gdi › SetSystemPaletteUse

SetSystemPaletteUse

関数
システムパレットの使用方法を設定する。
DLLGDI32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

DWORD SetSystemPaletteUse(
    HDC hdc,
    SYSTEM_PALETTE_USE use
);

パラメーター

名前方向
hdcHDCin
useSYSTEM_PALETTE_USEin

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD SetSystemPaletteUse(
    HDC hdc,
    SYSTEM_PALETTE_USE use
);
[DllImport("GDI32.dll", ExactSpelling = true)]
static extern uint SetSystemPaletteUse(
    IntPtr hdc,   // HDC
    uint use   // SYSTEM_PALETTE_USE
);
<DllImport("GDI32.dll", ExactSpelling:=True)>
Public Shared Function SetSystemPaletteUse(
    hdc As IntPtr,   ' HDC
    use As UInteger   ' SYSTEM_PALETTE_USE
) As UInteger
End Function
' hdc : HDC
' use : SYSTEM_PALETTE_USE
Declare PtrSafe Function SetSystemPaletteUse Lib "gdi32" ( _
    ByVal hdc As LongPtr, _
    ByVal use As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SetSystemPaletteUse = ctypes.windll.gdi32.SetSystemPaletteUse
SetSystemPaletteUse.restype = wintypes.DWORD
SetSystemPaletteUse.argtypes = [
    wintypes.HANDLE,  # hdc : HDC
    wintypes.DWORD,  # use : SYSTEM_PALETTE_USE
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('GDI32.dll')
SetSystemPaletteUse = Fiddle::Function.new(
  lib['SetSystemPaletteUse'],
  [
    Fiddle::TYPE_VOIDP,  # hdc : HDC
    -Fiddle::TYPE_INT,  # use : SYSTEM_PALETTE_USE
  ],
  -Fiddle::TYPE_INT)
#[link(name = "gdi32")]
extern "system" {
    fn SetSystemPaletteUse(
        hdc: *mut core::ffi::c_void,  // HDC
        use: u32  // SYSTEM_PALETTE_USE
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("GDI32.dll")]
public static extern uint SetSystemPaletteUse(IntPtr hdc, uint use);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_SetSystemPaletteUse' -Namespace Win32 -PassThru
# $api::SetSystemPaletteUse(hdc, use)
#uselib "GDI32.dll"
#func global SetSystemPaletteUse "SetSystemPaletteUse" sptr, sptr
; SetSystemPaletteUse hdc, use   ; 戻り値は stat
; hdc : HDC -> "sptr"
; use : SYSTEM_PALETTE_USE -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "GDI32.dll"
#cfunc global SetSystemPaletteUse "SetSystemPaletteUse" sptr, int
; res = SetSystemPaletteUse(hdc, use)
; hdc : HDC -> "sptr"
; use : SYSTEM_PALETTE_USE -> "int"
; DWORD SetSystemPaletteUse(HDC hdc, SYSTEM_PALETTE_USE use)
#uselib "GDI32.dll"
#cfunc global SetSystemPaletteUse "SetSystemPaletteUse" intptr, int
; res = SetSystemPaletteUse(hdc, use)
; hdc : HDC -> "intptr"
; use : SYSTEM_PALETTE_USE -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procSetSystemPaletteUse = gdi32.NewProc("SetSystemPaletteUse")
)

// hdc (HDC), use (SYSTEM_PALETTE_USE)
r1, _, err := procSetSystemPaletteUse.Call(
	uintptr(hdc),
	uintptr(use),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function SetSystemPaletteUse(
  hdc: THandle;   // HDC
  use: DWORD   // SYSTEM_PALETTE_USE
): DWORD; stdcall;
  external 'GDI32.dll' name 'SetSystemPaletteUse';
result := DllCall("GDI32\SetSystemPaletteUse"
    , "Ptr", hdc   ; HDC
    , "UInt", use   ; SYSTEM_PALETTE_USE
    , "UInt")   ; return: DWORD
●SetSystemPaletteUse(hdc, use) = DLL("GDI32.dll", "dword SetSystemPaletteUse(void*, dword)")
# 呼び出し: SetSystemPaletteUse(hdc, use)
# hdc : HDC -> "void*"
# use : SYSTEM_PALETTE_USE -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。