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

AnimatePalette

関数
論理パレットのエントリを置き換えてパレットアニメーションを行う。
DLLGDI32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

BOOL AnimatePalette(
    HPALETTE hPal,
    DWORD iStartIndex,
    DWORD cEntries,
    const PALETTEENTRY* ppe
);

パラメーター

名前方向
hPalHPALETTEin
iStartIndexDWORDin
cEntriesDWORDin
ppePALETTEENTRY*in

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL AnimatePalette(
    HPALETTE hPal,
    DWORD iStartIndex,
    DWORD cEntries,
    const PALETTEENTRY* ppe
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("GDI32.dll", ExactSpelling = true)]
static extern bool AnimatePalette(
    IntPtr hPal,   // HPALETTE
    uint iStartIndex,   // DWORD
    uint cEntries,   // DWORD
    IntPtr ppe   // PALETTEENTRY*
);
<DllImport("GDI32.dll", ExactSpelling:=True)>
Public Shared Function AnimatePalette(
    hPal As IntPtr,   ' HPALETTE
    iStartIndex As UInteger,   ' DWORD
    cEntries As UInteger,   ' DWORD
    ppe As IntPtr   ' PALETTEENTRY*
) As Boolean
End Function
' hPal : HPALETTE
' iStartIndex : DWORD
' cEntries : DWORD
' ppe : PALETTEENTRY*
Declare PtrSafe Function AnimatePalette Lib "gdi32" ( _
    ByVal hPal As LongPtr, _
    ByVal iStartIndex As Long, _
    ByVal cEntries As Long, _
    ByVal ppe As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

AnimatePalette = ctypes.windll.gdi32.AnimatePalette
AnimatePalette.restype = wintypes.BOOL
AnimatePalette.argtypes = [
    wintypes.HANDLE,  # hPal : HPALETTE
    wintypes.DWORD,  # iStartIndex : DWORD
    wintypes.DWORD,  # cEntries : DWORD
    ctypes.c_void_p,  # ppe : PALETTEENTRY*
]
require 'fiddle'
require 'fiddle/import'

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

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procAnimatePalette = gdi32.NewProc("AnimatePalette")
)

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