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

EnumMetaFile

関数
メタファイル内の各レコードを列挙しコールバックに渡す。
DLLGDI32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

BOOL EnumMetaFile(
    HDC hdc,
    HMETAFILE hmf,
    MFENUMPROC proc,
    LPARAM param3   // optional
);

パラメーター

名前方向
hdcHDCin
hmfHMETAFILEin
procMFENUMPROCin
param3LPARAMinoptional

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL EnumMetaFile(
    HDC hdc,
    HMETAFILE hmf,
    MFENUMPROC proc,
    LPARAM param3   // optional
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("GDI32.dll", ExactSpelling = true)]
static extern bool EnumMetaFile(
    IntPtr hdc,   // HDC
    IntPtr hmf,   // HMETAFILE
    IntPtr proc,   // MFENUMPROC
    IntPtr param3   // LPARAM optional
);
<DllImport("GDI32.dll", ExactSpelling:=True)>
Public Shared Function EnumMetaFile(
    hdc As IntPtr,   ' HDC
    hmf As IntPtr,   ' HMETAFILE
    proc As IntPtr,   ' MFENUMPROC
    param3 As IntPtr   ' LPARAM optional
) As Boolean
End Function
' hdc : HDC
' hmf : HMETAFILE
' proc : MFENUMPROC
' param3 : LPARAM optional
Declare PtrSafe Function EnumMetaFile Lib "gdi32" ( _
    ByVal hdc As LongPtr, _
    ByVal hmf As LongPtr, _
    ByVal proc As LongPtr, _
    ByVal param3 As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

EnumMetaFile = ctypes.windll.gdi32.EnumMetaFile
EnumMetaFile.restype = wintypes.BOOL
EnumMetaFile.argtypes = [
    wintypes.HANDLE,  # hdc : HDC
    wintypes.HANDLE,  # hmf : HMETAFILE
    ctypes.c_void_p,  # proc : MFENUMPROC
    ctypes.c_ssize_t,  # param3 : LPARAM optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('GDI32.dll')
EnumMetaFile = Fiddle::Function.new(
  lib['EnumMetaFile'],
  [
    Fiddle::TYPE_VOIDP,  # hdc : HDC
    Fiddle::TYPE_VOIDP,  # hmf : HMETAFILE
    Fiddle::TYPE_VOIDP,  # proc : MFENUMPROC
    Fiddle::TYPE_INTPTR_T,  # param3 : LPARAM optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "gdi32")]
extern "system" {
    fn EnumMetaFile(
        hdc: *mut core::ffi::c_void,  // HDC
        hmf: *mut core::ffi::c_void,  // HMETAFILE
        proc: *const core::ffi::c_void,  // MFENUMPROC
        param3: isize  // LPARAM optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("GDI32.dll")]
public static extern bool EnumMetaFile(IntPtr hdc, IntPtr hmf, IntPtr proc, IntPtr param3);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_EnumMetaFile' -Namespace Win32 -PassThru
# $api::EnumMetaFile(hdc, hmf, proc, param3)
#uselib "GDI32.dll"
#func global EnumMetaFile "EnumMetaFile" sptr, sptr, sptr, sptr
; EnumMetaFile hdc, hmf, proc, param3   ; 戻り値は stat
; hdc : HDC -> "sptr"
; hmf : HMETAFILE -> "sptr"
; proc : MFENUMPROC -> "sptr"
; param3 : LPARAM optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "GDI32.dll"
#cfunc global EnumMetaFile "EnumMetaFile" sptr, sptr, sptr, sptr
; res = EnumMetaFile(hdc, hmf, proc, param3)
; hdc : HDC -> "sptr"
; hmf : HMETAFILE -> "sptr"
; proc : MFENUMPROC -> "sptr"
; param3 : LPARAM optional -> "sptr"
; BOOL EnumMetaFile(HDC hdc, HMETAFILE hmf, MFENUMPROC proc, LPARAM param3)
#uselib "GDI32.dll"
#cfunc global EnumMetaFile "EnumMetaFile" intptr, intptr, intptr, intptr
; res = EnumMetaFile(hdc, hmf, proc, param3)
; hdc : HDC -> "intptr"
; hmf : HMETAFILE -> "intptr"
; proc : MFENUMPROC -> "intptr"
; param3 : LPARAM optional -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procEnumMetaFile = gdi32.NewProc("EnumMetaFile")
)

// hdc (HDC), hmf (HMETAFILE), proc (MFENUMPROC), param3 (LPARAM optional)
r1, _, err := procEnumMetaFile.Call(
	uintptr(hdc),
	uintptr(hmf),
	uintptr(proc),
	uintptr(param3),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function EnumMetaFile(
  hdc: THandle;   // HDC
  hmf: THandle;   // HMETAFILE
  proc: Pointer;   // MFENUMPROC
  param3: NativeInt   // LPARAM optional
): BOOL; stdcall;
  external 'GDI32.dll' name 'EnumMetaFile';
result := DllCall("GDI32\EnumMetaFile"
    , "Ptr", hdc   ; HDC
    , "Ptr", hmf   ; HMETAFILE
    , "Ptr", proc   ; MFENUMPROC
    , "Ptr", param3   ; LPARAM optional
    , "Int")   ; return: BOOL
●EnumMetaFile(hdc, hmf, proc, param3) = DLL("GDI32.dll", "bool EnumMetaFile(void*, void*, void*, int)")
# 呼び出し: EnumMetaFile(hdc, hmf, proc, param3)
# hdc : HDC -> "void*"
# hmf : HMETAFILE -> "void*"
# proc : MFENUMPROC -> "void*"
# param3 : LPARAM optional -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。