Win32 API 日本語リファレンス
ホームDevices.Display › EngCreatePalette

EngCreatePalette

関数
GDIパレットを作成する。
DLLGDI32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

HPALETTE EngCreatePalette(
    DWORD iMode,
    DWORD cColors,
    DWORD* pulColors,
    DWORD flRed,
    DWORD flGreen,
    DWORD flBlue
);

パラメーター

名前方向
iModeDWORDin
cColorsDWORDin
pulColorsDWORD*inout
flRedDWORDin
flGreenDWORDin
flBlueDWORDin

戻り値の型: HPALETTE

各言語での呼び出し定義

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

HPALETTE EngCreatePalette(
    DWORD iMode,
    DWORD cColors,
    DWORD* pulColors,
    DWORD flRed,
    DWORD flGreen,
    DWORD flBlue
);
[DllImport("GDI32.dll", ExactSpelling = true)]
static extern IntPtr EngCreatePalette(
    uint iMode,   // DWORD
    uint cColors,   // DWORD
    ref uint pulColors,   // DWORD* in/out
    uint flRed,   // DWORD
    uint flGreen,   // DWORD
    uint flBlue   // DWORD
);
<DllImport("GDI32.dll", ExactSpelling:=True)>
Public Shared Function EngCreatePalette(
    iMode As UInteger,   ' DWORD
    cColors As UInteger,   ' DWORD
    ByRef pulColors As UInteger,   ' DWORD* in/out
    flRed As UInteger,   ' DWORD
    flGreen As UInteger,   ' DWORD
    flBlue As UInteger   ' DWORD
) As IntPtr
End Function
' iMode : DWORD
' cColors : DWORD
' pulColors : DWORD* in/out
' flRed : DWORD
' flGreen : DWORD
' flBlue : DWORD
Declare PtrSafe Function EngCreatePalette Lib "gdi32" ( _
    ByVal iMode As Long, _
    ByVal cColors As Long, _
    ByRef pulColors As Long, _
    ByVal flRed As Long, _
    ByVal flGreen As Long, _
    ByVal flBlue As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

EngCreatePalette = ctypes.windll.gdi32.EngCreatePalette
EngCreatePalette.restype = ctypes.c_void_p
EngCreatePalette.argtypes = [
    wintypes.DWORD,  # iMode : DWORD
    wintypes.DWORD,  # cColors : DWORD
    ctypes.POINTER(wintypes.DWORD),  # pulColors : DWORD* in/out
    wintypes.DWORD,  # flRed : DWORD
    wintypes.DWORD,  # flGreen : DWORD
    wintypes.DWORD,  # flBlue : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('GDI32.dll')
EngCreatePalette = Fiddle::Function.new(
  lib['EngCreatePalette'],
  [
    -Fiddle::TYPE_INT,  # iMode : DWORD
    -Fiddle::TYPE_INT,  # cColors : DWORD
    Fiddle::TYPE_VOIDP,  # pulColors : DWORD* in/out
    -Fiddle::TYPE_INT,  # flRed : DWORD
    -Fiddle::TYPE_INT,  # flGreen : DWORD
    -Fiddle::TYPE_INT,  # flBlue : DWORD
  ],
  Fiddle::TYPE_VOIDP)
#[link(name = "gdi32")]
extern "system" {
    fn EngCreatePalette(
        iMode: u32,  // DWORD
        cColors: u32,  // DWORD
        pulColors: *mut u32,  // DWORD* in/out
        flRed: u32,  // DWORD
        flGreen: u32,  // DWORD
        flBlue: u32  // DWORD
    ) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("GDI32.dll")]
public static extern IntPtr EngCreatePalette(uint iMode, uint cColors, ref uint pulColors, uint flRed, uint flGreen, uint flBlue);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_EngCreatePalette' -Namespace Win32 -PassThru
# $api::EngCreatePalette(iMode, cColors, pulColors, flRed, flGreen, flBlue)
#uselib "GDI32.dll"
#func global EngCreatePalette "EngCreatePalette" sptr, sptr, sptr, sptr, sptr, sptr
; EngCreatePalette iMode, cColors, varptr(pulColors), flRed, flGreen, flBlue   ; 戻り値は stat
; iMode : DWORD -> "sptr"
; cColors : DWORD -> "sptr"
; pulColors : DWORD* in/out -> "sptr"
; flRed : DWORD -> "sptr"
; flGreen : DWORD -> "sptr"
; flBlue : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "GDI32.dll"
#cfunc global EngCreatePalette "EngCreatePalette" int, int, var, int, int, int
; res = EngCreatePalette(iMode, cColors, pulColors, flRed, flGreen, flBlue)
; iMode : DWORD -> "int"
; cColors : DWORD -> "int"
; pulColors : DWORD* in/out -> "var"
; flRed : DWORD -> "int"
; flGreen : DWORD -> "int"
; flBlue : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HPALETTE EngCreatePalette(DWORD iMode, DWORD cColors, DWORD* pulColors, DWORD flRed, DWORD flGreen, DWORD flBlue)
#uselib "GDI32.dll"
#cfunc global EngCreatePalette "EngCreatePalette" int, int, var, int, int, int
; res = EngCreatePalette(iMode, cColors, pulColors, flRed, flGreen, flBlue)
; iMode : DWORD -> "int"
; cColors : DWORD -> "int"
; pulColors : DWORD* in/out -> "var"
; flRed : DWORD -> "int"
; flGreen : DWORD -> "int"
; flBlue : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procEngCreatePalette = gdi32.NewProc("EngCreatePalette")
)

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