ホーム › UI.WindowsAndMessaging › DrawIconEx
DrawIconEx
関数指定位置にアイコンまたはカーソルを描画する。
シグネチャ
// USER32.dll
#include <windows.h>
BOOL DrawIconEx(
HDC hdc,
INT xLeft,
INT yTop,
HICON hIcon,
INT cxWidth,
INT cyWidth,
DWORD istepIfAniCur,
HBRUSH hbrFlickerFreeDraw, // optional
DI_FLAGS diFlags
);パラメーター
| 名前 | 型 | 方向 | 説明 | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| hdc | HDC | in | アイコンまたはカーソルの描画先となるデバイスコンテキストへのハンドル。 | ||||||||||||||
| xLeft | INT | in | アイコンまたはカーソルの左上隅の論理 x 座標。 | ||||||||||||||
| yTop | INT | in | アイコンまたはカーソルの左上隅の論理 y 座標。 | ||||||||||||||
| hIcon | HICON | in | 描画するアイコンまたはカーソルへのハンドル。このパラメーターはアニメーションカーソルを指定できます。 | ||||||||||||||
| cxWidth | INT | in | アイコンまたはカーソルの論理幅。このパラメーターが 0 で、diFlags パラメーターが DI_DEFAULTSIZE の場合、関数は幅の設定に SM_CXICON システムメトリック値を使用します。このパラメーターが 0 で DI_DEFAULTSIZE を使用しない場合、関数は実際のリソース幅を使用します。 | ||||||||||||||
| cyWidth | INT | in | アイコンまたはカーソルの論理高さ。このパラメーターが 0 で、diFlags パラメーターが DI_DEFAULTSIZE の場合、関数は幅の設定に SM_CYICON システムメトリック値を使用します。このパラメーターが 0 で DI_DEFAULTSIZE を使用しない場合、関数は実際のリソース高さを使用します。 | ||||||||||||||
| istepIfAniCur | DWORD | in | hIcon がアニメーションカーソルを指定している場合に描画するフレームのインデックス。hIcon がアニメーションカーソルを指定していない場合、このパラメーターは無視されます。 | ||||||||||||||
| hbrFlickerFreeDraw | HBRUSH | inoptional | ちらつきのない描画のためにシステムが使用するブラシへのハンドル。hbrFlickerFreeDraw が有効なブラシハンドルである場合、システムは指定されたブラシを背景色として使用してオフスクリーンビットマップを作成し、そのビットマップにアイコンまたはカーソルを描画してから、hdc で指定されたデバイスコンテキストにビットマップをコピーします。hbrFlickerFreeDraw が NULL の場合、システムはアイコンまたはカーソルをデバイスコンテキストに直接描画します。 | ||||||||||||||
| diFlags | DI_FLAGS | in | 描画フラグ。このパラメーターには次のいずれかの値を指定できます。
|
戻り値の型: BOOL
公式ドキュメント
指定したデバイスコンテキストにアイコンまたはカーソルを描画します。指定したラスター演算を実行し、アイコンまたはカーソルを指定どおりに拡大または縮小します。
戻り値
解説(Remarks)
DrawIconEx 関数は、アイコンの左上隅を xLeft および yTop パラメーターで指定された位置に配置します。この位置は、デバイスコンテキストの現在のマッピングモードの影響を受けます。
DI_IMAGE と DI_MASK のフラグのうち一方のみが設定されている場合、対応するビットマップは SRCCOPY ラスター演算コード で描画されます。
DI_IMAGE と DI_MASK の両方のフラグが設定されている場合:
- アイコンまたはカーソルが 32 ビットのアルファブレンドされたアイコンまたはカーソルである場合、イメージは AC_SRC_OVER ブレンド関数 で描画され、マスクは無視されます。
- その他のすべてのアイコンまたはカーソルでは、マスクは SRCAND ラスター演算コード で描画され、イメージは SRCINVERT ラスター演算コード で描画されます
DrawIcon (hDC, X, Y, hIcon) と同じ動作にするには、次のように DrawIconEx を呼び出します:
DrawIconEx (hDC, X, Y, hIcon, 0, 0, 0, NULL, DI_NORMAL | DI_COMPAT | DI_DEFAULTSIZE);
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// USER32.dll
#include <windows.h>
BOOL DrawIconEx(
HDC hdc,
INT xLeft,
INT yTop,
HICON hIcon,
INT cxWidth,
INT cyWidth,
DWORD istepIfAniCur,
HBRUSH hbrFlickerFreeDraw, // optional
DI_FLAGS diFlags
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool DrawIconEx(
IntPtr hdc, // HDC
int xLeft, // INT
int yTop, // INT
IntPtr hIcon, // HICON
int cxWidth, // INT
int cyWidth, // INT
uint istepIfAniCur, // DWORD
IntPtr hbrFlickerFreeDraw, // HBRUSH optional
uint diFlags // DI_FLAGS
);<DllImport("USER32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function DrawIconEx(
hdc As IntPtr, ' HDC
xLeft As Integer, ' INT
yTop As Integer, ' INT
hIcon As IntPtr, ' HICON
cxWidth As Integer, ' INT
cyWidth As Integer, ' INT
istepIfAniCur As UInteger, ' DWORD
hbrFlickerFreeDraw As IntPtr, ' HBRUSH optional
diFlags As UInteger ' DI_FLAGS
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' hdc : HDC
' xLeft : INT
' yTop : INT
' hIcon : HICON
' cxWidth : INT
' cyWidth : INT
' istepIfAniCur : DWORD
' hbrFlickerFreeDraw : HBRUSH optional
' diFlags : DI_FLAGS
Declare PtrSafe Function DrawIconEx Lib "user32" ( _
ByVal hdc As LongPtr, _
ByVal xLeft As Long, _
ByVal yTop As Long, _
ByVal hIcon As LongPtr, _
ByVal cxWidth As Long, _
ByVal cyWidth As Long, _
ByVal istepIfAniCur As Long, _
ByVal hbrFlickerFreeDraw As LongPtr, _
ByVal diFlags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DrawIconEx = ctypes.windll.user32.DrawIconEx
DrawIconEx.restype = wintypes.BOOL
DrawIconEx.argtypes = [
wintypes.HANDLE, # hdc : HDC
ctypes.c_int, # xLeft : INT
ctypes.c_int, # yTop : INT
wintypes.HANDLE, # hIcon : HICON
ctypes.c_int, # cxWidth : INT
ctypes.c_int, # cyWidth : INT
wintypes.DWORD, # istepIfAniCur : DWORD
wintypes.HANDLE, # hbrFlickerFreeDraw : HBRUSH optional
wintypes.DWORD, # diFlags : DI_FLAGS
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USER32.dll')
DrawIconEx = Fiddle::Function.new(
lib['DrawIconEx'],
[
Fiddle::TYPE_VOIDP, # hdc : HDC
Fiddle::TYPE_INT, # xLeft : INT
Fiddle::TYPE_INT, # yTop : INT
Fiddle::TYPE_VOIDP, # hIcon : HICON
Fiddle::TYPE_INT, # cxWidth : INT
Fiddle::TYPE_INT, # cyWidth : INT
-Fiddle::TYPE_INT, # istepIfAniCur : DWORD
Fiddle::TYPE_VOIDP, # hbrFlickerFreeDraw : HBRUSH optional
-Fiddle::TYPE_INT, # diFlags : DI_FLAGS
],
Fiddle::TYPE_INT)#[link(name = "user32")]
extern "system" {
fn DrawIconEx(
hdc: *mut core::ffi::c_void, // HDC
xLeft: i32, // INT
yTop: i32, // INT
hIcon: *mut core::ffi::c_void, // HICON
cxWidth: i32, // INT
cyWidth: i32, // INT
istepIfAniCur: u32, // DWORD
hbrFlickerFreeDraw: *mut core::ffi::c_void, // HBRUSH optional
diFlags: u32 // DI_FLAGS
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", SetLastError = true)]
public static extern bool DrawIconEx(IntPtr hdc, int xLeft, int yTop, IntPtr hIcon, int cxWidth, int cyWidth, uint istepIfAniCur, IntPtr hbrFlickerFreeDraw, uint diFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_DrawIconEx' -Namespace Win32 -PassThru
# $api::DrawIconEx(hdc, xLeft, yTop, hIcon, cxWidth, cyWidth, istepIfAniCur, hbrFlickerFreeDraw, diFlags)#uselib "USER32.dll"
#func global DrawIconEx "DrawIconEx" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; DrawIconEx hdc, xLeft, yTop, hIcon, cxWidth, cyWidth, istepIfAniCur, hbrFlickerFreeDraw, diFlags ; 戻り値は stat
; hdc : HDC -> "sptr"
; xLeft : INT -> "sptr"
; yTop : INT -> "sptr"
; hIcon : HICON -> "sptr"
; cxWidth : INT -> "sptr"
; cyWidth : INT -> "sptr"
; istepIfAniCur : DWORD -> "sptr"
; hbrFlickerFreeDraw : HBRUSH optional -> "sptr"
; diFlags : DI_FLAGS -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "USER32.dll"
#cfunc global DrawIconEx "DrawIconEx" sptr, int, int, sptr, int, int, int, sptr, int
; res = DrawIconEx(hdc, xLeft, yTop, hIcon, cxWidth, cyWidth, istepIfAniCur, hbrFlickerFreeDraw, diFlags)
; hdc : HDC -> "sptr"
; xLeft : INT -> "int"
; yTop : INT -> "int"
; hIcon : HICON -> "sptr"
; cxWidth : INT -> "int"
; cyWidth : INT -> "int"
; istepIfAniCur : DWORD -> "int"
; hbrFlickerFreeDraw : HBRUSH optional -> "sptr"
; diFlags : DI_FLAGS -> "int"; BOOL DrawIconEx(HDC hdc, INT xLeft, INT yTop, HICON hIcon, INT cxWidth, INT cyWidth, DWORD istepIfAniCur, HBRUSH hbrFlickerFreeDraw, DI_FLAGS diFlags)
#uselib "USER32.dll"
#cfunc global DrawIconEx "DrawIconEx" intptr, int, int, intptr, int, int, int, intptr, int
; res = DrawIconEx(hdc, xLeft, yTop, hIcon, cxWidth, cyWidth, istepIfAniCur, hbrFlickerFreeDraw, diFlags)
; hdc : HDC -> "intptr"
; xLeft : INT -> "int"
; yTop : INT -> "int"
; hIcon : HICON -> "intptr"
; cxWidth : INT -> "int"
; cyWidth : INT -> "int"
; istepIfAniCur : DWORD -> "int"
; hbrFlickerFreeDraw : HBRUSH optional -> "intptr"
; diFlags : DI_FLAGS -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
user32 = windows.NewLazySystemDLL("USER32.dll")
procDrawIconEx = user32.NewProc("DrawIconEx")
)
// hdc (HDC), xLeft (INT), yTop (INT), hIcon (HICON), cxWidth (INT), cyWidth (INT), istepIfAniCur (DWORD), hbrFlickerFreeDraw (HBRUSH optional), diFlags (DI_FLAGS)
r1, _, err := procDrawIconEx.Call(
uintptr(hdc),
uintptr(xLeft),
uintptr(yTop),
uintptr(hIcon),
uintptr(cxWidth),
uintptr(cyWidth),
uintptr(istepIfAniCur),
uintptr(hbrFlickerFreeDraw),
uintptr(diFlags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction DrawIconEx(
hdc: THandle; // HDC
xLeft: Integer; // INT
yTop: Integer; // INT
hIcon: THandle; // HICON
cxWidth: Integer; // INT
cyWidth: Integer; // INT
istepIfAniCur: DWORD; // DWORD
hbrFlickerFreeDraw: THandle; // HBRUSH optional
diFlags: DWORD // DI_FLAGS
): BOOL; stdcall;
external 'USER32.dll' name 'DrawIconEx';result := DllCall("USER32\DrawIconEx"
, "Ptr", hdc ; HDC
, "Int", xLeft ; INT
, "Int", yTop ; INT
, "Ptr", hIcon ; HICON
, "Int", cxWidth ; INT
, "Int", cyWidth ; INT
, "UInt", istepIfAniCur ; DWORD
, "Ptr", hbrFlickerFreeDraw ; HBRUSH optional
, "UInt", diFlags ; DI_FLAGS
, "Int") ; return: BOOL●DrawIconEx(hdc, xLeft, yTop, hIcon, cxWidth, cyWidth, istepIfAniCur, hbrFlickerFreeDraw, diFlags) = DLL("USER32.dll", "bool DrawIconEx(void*, int, int, void*, int, int, dword, void*, dword)")
# 呼び出し: DrawIconEx(hdc, xLeft, yTop, hIcon, cxWidth, cyWidth, istepIfAniCur, hbrFlickerFreeDraw, diFlags)
# hdc : HDC -> "void*"
# xLeft : INT -> "int"
# yTop : INT -> "int"
# hIcon : HICON -> "void*"
# cxWidth : INT -> "int"
# cyWidth : INT -> "int"
# istepIfAniCur : DWORD -> "dword"
# hbrFlickerFreeDraw : HBRUSH optional -> "void*"
# diFlags : DI_FLAGS -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "user32" fn DrawIconEx(
hdc: ?*anyopaque, // HDC
xLeft: i32, // INT
yTop: i32, // INT
hIcon: ?*anyopaque, // HICON
cxWidth: i32, // INT
cyWidth: i32, // INT
istepIfAniCur: u32, // DWORD
hbrFlickerFreeDraw: ?*anyopaque, // HBRUSH optional
diFlags: u32 // DI_FLAGS
) callconv(std.os.windows.WINAPI) i32;proc DrawIconEx(
hdc: pointer, # HDC
xLeft: int32, # INT
yTop: int32, # INT
hIcon: pointer, # HICON
cxWidth: int32, # INT
cyWidth: int32, # INT
istepIfAniCur: uint32, # DWORD
hbrFlickerFreeDraw: pointer, # HBRUSH optional
diFlags: uint32 # DI_FLAGS
): int32 {.importc: "DrawIconEx", stdcall, dynlib: "USER32.dll".}pragma(lib, "user32");
extern(Windows)
int DrawIconEx(
void* hdc, // HDC
int xLeft, // INT
int yTop, // INT
void* hIcon, // HICON
int cxWidth, // INT
int cyWidth, // INT
uint istepIfAniCur, // DWORD
void* hbrFlickerFreeDraw, // HBRUSH optional
uint diFlags // DI_FLAGS
);ccall((:DrawIconEx, "USER32.dll"), stdcall, Int32,
(Ptr{Cvoid}, Int32, Int32, Ptr{Cvoid}, Int32, Int32, UInt32, Ptr{Cvoid}, UInt32),
hdc, xLeft, yTop, hIcon, cxWidth, cyWidth, istepIfAniCur, hbrFlickerFreeDraw, diFlags)
# hdc : HDC -> Ptr{Cvoid}
# xLeft : INT -> Int32
# yTop : INT -> Int32
# hIcon : HICON -> Ptr{Cvoid}
# cxWidth : INT -> Int32
# cyWidth : INT -> Int32
# istepIfAniCur : DWORD -> UInt32
# hbrFlickerFreeDraw : HBRUSH optional -> Ptr{Cvoid}
# diFlags : DI_FLAGS -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t DrawIconEx(
void* hdc,
int32_t xLeft,
int32_t yTop,
void* hIcon,
int32_t cxWidth,
int32_t cyWidth,
uint32_t istepIfAniCur,
void* hbrFlickerFreeDraw,
uint32_t diFlags);
]]
local user32 = ffi.load("user32")
-- user32.DrawIconEx(hdc, xLeft, yTop, hIcon, cxWidth, cyWidth, istepIfAniCur, hbrFlickerFreeDraw, diFlags)
-- hdc : HDC
-- xLeft : INT
-- yTop : INT
-- hIcon : HICON
-- cxWidth : INT
-- cyWidth : INT
-- istepIfAniCur : DWORD
-- hbrFlickerFreeDraw : HBRUSH optional
-- diFlags : DI_FLAGS
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('USER32.dll');
const DrawIconEx = lib.func('__stdcall', 'DrawIconEx', 'int32_t', ['void *', 'int32_t', 'int32_t', 'void *', 'int32_t', 'int32_t', 'uint32_t', 'void *', 'uint32_t']);
// DrawIconEx(hdc, xLeft, yTop, hIcon, cxWidth, cyWidth, istepIfAniCur, hbrFlickerFreeDraw, diFlags)
// hdc : HDC -> 'void *'
// xLeft : INT -> 'int32_t'
// yTop : INT -> 'int32_t'
// hIcon : HICON -> 'void *'
// cxWidth : INT -> 'int32_t'
// cyWidth : INT -> 'int32_t'
// istepIfAniCur : DWORD -> 'uint32_t'
// hbrFlickerFreeDraw : HBRUSH optional -> 'void *'
// diFlags : DI_FLAGS -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("USER32.dll", {
DrawIconEx: { parameters: ["pointer", "i32", "i32", "pointer", "i32", "i32", "u32", "pointer", "u32"], result: "i32" },
});
// lib.symbols.DrawIconEx(hdc, xLeft, yTop, hIcon, cxWidth, cyWidth, istepIfAniCur, hbrFlickerFreeDraw, diFlags)
// hdc : HDC -> "pointer"
// xLeft : INT -> "i32"
// yTop : INT -> "i32"
// hIcon : HICON -> "pointer"
// cxWidth : INT -> "i32"
// cyWidth : INT -> "i32"
// istepIfAniCur : DWORD -> "u32"
// hbrFlickerFreeDraw : HBRUSH optional -> "pointer"
// diFlags : DI_FLAGS -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t DrawIconEx(
void* hdc,
int32_t xLeft,
int32_t yTop,
void* hIcon,
int32_t cxWidth,
int32_t cyWidth,
uint32_t istepIfAniCur,
void* hbrFlickerFreeDraw,
uint32_t diFlags);
C, "USER32.dll");
// $ffi->DrawIconEx(hdc, xLeft, yTop, hIcon, cxWidth, cyWidth, istepIfAniCur, hbrFlickerFreeDraw, diFlags);
// hdc : HDC
// xLeft : INT
// yTop : INT
// hIcon : HICON
// cxWidth : INT
// cyWidth : INT
// istepIfAniCur : DWORD
// hbrFlickerFreeDraw : HBRUSH optional
// diFlags : DI_FLAGS
// 構造体/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 User32 extends StdCallLibrary {
User32 INSTANCE = Native.load("user32", User32.class);
boolean DrawIconEx(
Pointer hdc, // HDC
int xLeft, // INT
int yTop, // INT
Pointer hIcon, // HICON
int cxWidth, // INT
int cyWidth, // INT
int istepIfAniCur, // DWORD
Pointer hbrFlickerFreeDraw, // HBRUSH optional
int diFlags // DI_FLAGS
);
}@[Link("user32")]
lib LibUSER32
fun DrawIconEx = DrawIconEx(
hdc : Void*, # HDC
xLeft : Int32, # INT
yTop : Int32, # INT
hIcon : Void*, # HICON
cxWidth : Int32, # INT
cyWidth : Int32, # INT
istepIfAniCur : UInt32, # DWORD
hbrFlickerFreeDraw : Void*, # HBRUSH optional
diFlags : UInt32 # DI_FLAGS
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef DrawIconExNative = Int32 Function(Pointer<Void>, Int32, Int32, Pointer<Void>, Int32, Int32, Uint32, Pointer<Void>, Uint32);
typedef DrawIconExDart = int Function(Pointer<Void>, int, int, Pointer<Void>, int, int, int, Pointer<Void>, int);
final DrawIconEx = DynamicLibrary.open('USER32.dll')
.lookupFunction<DrawIconExNative, DrawIconExDart>('DrawIconEx');
// hdc : HDC -> Pointer<Void>
// xLeft : INT -> Int32
// yTop : INT -> Int32
// hIcon : HICON -> Pointer<Void>
// cxWidth : INT -> Int32
// cyWidth : INT -> Int32
// istepIfAniCur : DWORD -> Uint32
// hbrFlickerFreeDraw : HBRUSH optional -> Pointer<Void>
// diFlags : DI_FLAGS -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function DrawIconEx(
hdc: THandle; // HDC
xLeft: Integer; // INT
yTop: Integer; // INT
hIcon: THandle; // HICON
cxWidth: Integer; // INT
cyWidth: Integer; // INT
istepIfAniCur: DWORD; // DWORD
hbrFlickerFreeDraw: THandle; // HBRUSH optional
diFlags: DWORD // DI_FLAGS
): BOOL; stdcall;
external 'USER32.dll' name 'DrawIconEx';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "DrawIconEx"
c_DrawIconEx :: Ptr () -> Int32 -> Int32 -> Ptr () -> Int32 -> Int32 -> Word32 -> Ptr () -> Word32 -> IO CInt
-- hdc : HDC -> Ptr ()
-- xLeft : INT -> Int32
-- yTop : INT -> Int32
-- hIcon : HICON -> Ptr ()
-- cxWidth : INT -> Int32
-- cyWidth : INT -> Int32
-- istepIfAniCur : DWORD -> Word32
-- hbrFlickerFreeDraw : HBRUSH optional -> Ptr ()
-- diFlags : DI_FLAGS -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let drawiconex =
foreign "DrawIconEx"
((ptr void) @-> int32_t @-> int32_t @-> (ptr void) @-> int32_t @-> int32_t @-> uint32_t @-> (ptr void) @-> uint32_t @-> returning int32_t)
(* hdc : HDC -> (ptr void) *)
(* xLeft : INT -> int32_t *)
(* yTop : INT -> int32_t *)
(* hIcon : HICON -> (ptr void) *)
(* cxWidth : INT -> int32_t *)
(* cyWidth : INT -> int32_t *)
(* istepIfAniCur : DWORD -> uint32_t *)
(* hbrFlickerFreeDraw : HBRUSH optional -> (ptr void) *)
(* diFlags : DI_FLAGS -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library user32 (t "USER32.dll"))
(cffi:use-foreign-library user32)
(cffi:defcfun ("DrawIconEx" draw-icon-ex :convention :stdcall) :int32
(hdc :pointer) ; HDC
(x-left :int32) ; INT
(y-top :int32) ; INT
(h-icon :pointer) ; HICON
(cx-width :int32) ; INT
(cy-width :int32) ; INT
(istep-if-ani-cur :uint32) ; DWORD
(hbr-flicker-free-draw :pointer) ; HBRUSH optional
(di-flags :uint32)) ; DI_FLAGS
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $DrawIconEx = Win32::API::More->new('USER32',
'BOOL DrawIconEx(HANDLE hdc, int xLeft, int yTop, HANDLE hIcon, int cxWidth, int cyWidth, DWORD istepIfAniCur, HANDLE hbrFlickerFreeDraw, DWORD diFlags)');
# my $ret = $DrawIconEx->Call($hdc, $xLeft, $yTop, $hIcon, $cxWidth, $cyWidth, $istepIfAniCur, $hbrFlickerFreeDraw, $diFlags);
# hdc : HDC -> HANDLE
# xLeft : INT -> int
# yTop : INT -> int
# hIcon : HICON -> HANDLE
# cxWidth : INT -> int
# cyWidth : INT -> int
# istepIfAniCur : DWORD -> DWORD
# hbrFlickerFreeDraw : HBRUSH optional -> HANDLE
# diFlags : DI_FLAGS -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
類似 API
- f DrawIcon — 指定デバイスコンテキストの座標にアイコンを描画する。
公式の関連項目
- f CopyImage — アイコン・カーソル・ビットマップの複製を作成する。
- f LoadImageW — アイコン・カーソル・ビットマップを読み込む(Unicode版)。
- f BitBlt — デバイスコンテキスト間でビットマップのブロック転送を行う。
- f AlphaBlend — アルファ値を用いて2つのビットマップを半透明合成する。
- s BLENDFUNCTION
使用する型