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

ENHMETAHEADER3

構造体
サイズx64: 88 バイト / x86: 88 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
iTypeDWORD4+0+0レコード種別。拡張メタファイルの先頭レコードを示す。
nSizeDWORD4+4+4このヘッダのサイズをバイト単位で表す。
rclBoundsRECTL16+8+8図形の外接矩形をデバイス単位で表すRECTL構造体。
rclFrameRECTL16+24+24図形の枠を0.01mm単位で表すRECTL構造体。
dSignatureDWORD4+40+40拡張メタファイルの署名(ENHMETA_SIGNATURE)を表す。
nVersionDWORD4+44+44メタファイルのバージョン番号を表す。
nBytesDWORD4+48+48メタファイル全体のサイズをバイト単位で表す。
nRecordsDWORD4+52+52メタファイル内のレコード総数を表す。
nHandlesWORD2+56+56ハンドルテーブルのエントリ数を表す。
sReservedWORD2+58+58予約済みフィールド。0でなければならない。
nDescriptionDWORD4+60+60説明文字列の文字数を表す。
offDescriptionDWORD4+64+64ヘッダ先頭から説明文字列へのオフセットをバイト単位で表す。
nPalEntriesDWORD4+68+68メタファイルのパレットエントリ数を表す。
szlDeviceSIZE8+72+72参照デバイスの解像度(ピクセル)を表すSIZE構造体。
szlMillimetersSIZE8+80+80参照デバイスのサイズ(ミリメートル)を表すSIZE構造体。

各言語での定義

#include <windows.h>

// RECTL  (x64 16 / x86 16 バイト)
typedef struct RECTL {
    INT left;
    INT top;
    INT right;
    INT bottom;
} RECTL;

// SIZE  (x64 8 / x86 8 バイト)
typedef struct SIZE {
    INT cx;
    INT cy;
} SIZE;

// ENHMETAHEADER3  (x64 88 / x86 88 バイト)
typedef struct ENHMETAHEADER3 {
    DWORD iType;
    DWORD nSize;
    RECTL rclBounds;
    RECTL rclFrame;
    DWORD dSignature;
    DWORD nVersion;
    DWORD nBytes;
    DWORD nRecords;
    WORD nHandles;
    WORD sReserved;
    DWORD nDescription;
    DWORD offDescription;
    DWORD nPalEntries;
    SIZE szlDevice;
    SIZE szlMillimeters;
} ENHMETAHEADER3;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct RECTL
{
    public int left;
    public int top;
    public int right;
    public int bottom;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SIZE
{
    public int cx;
    public int cy;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct ENHMETAHEADER3
{
    public uint iType;
    public uint nSize;
    public RECTL rclBounds;
    public RECTL rclFrame;
    public uint dSignature;
    public uint nVersion;
    public uint nBytes;
    public uint nRecords;
    public ushort nHandles;
    public ushort sReserved;
    public uint nDescription;
    public uint offDescription;
    public uint nPalEntries;
    public SIZE szlDevice;
    public SIZE szlMillimeters;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure RECTL
    Public left As Integer
    Public top As Integer
    Public right As Integer
    Public bottom As Integer
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SIZE
    Public cx As Integer
    Public cy As Integer
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure ENHMETAHEADER3
    Public iType As UInteger
    Public nSize As UInteger
    Public rclBounds As RECTL
    Public rclFrame As RECTL
    Public dSignature As UInteger
    Public nVersion As UInteger
    Public nBytes As UInteger
    Public nRecords As UInteger
    Public nHandles As UShort
    Public sReserved As UShort
    Public nDescription As UInteger
    Public offDescription As UInteger
    Public nPalEntries As UInteger
    Public szlDevice As SIZE
    Public szlMillimeters As SIZE
End Structure
import ctypes
from ctypes import wintypes

class RECTL(ctypes.Structure):
    _fields_ = [
        ("left", ctypes.c_int),
        ("top", ctypes.c_int),
        ("right", ctypes.c_int),
        ("bottom", ctypes.c_int),
    ]

class SIZE(ctypes.Structure):
    _fields_ = [
        ("cx", ctypes.c_int),
        ("cy", ctypes.c_int),
    ]

class ENHMETAHEADER3(ctypes.Structure):
    _fields_ = [
        ("iType", wintypes.DWORD),
        ("nSize", wintypes.DWORD),
        ("rclBounds", RECTL),
        ("rclFrame", RECTL),
        ("dSignature", wintypes.DWORD),
        ("nVersion", wintypes.DWORD),
        ("nBytes", wintypes.DWORD),
        ("nRecords", wintypes.DWORD),
        ("nHandles", ctypes.c_ushort),
        ("sReserved", ctypes.c_ushort),
        ("nDescription", wintypes.DWORD),
        ("offDescription", wintypes.DWORD),
        ("nPalEntries", wintypes.DWORD),
        ("szlDevice", SIZE),
        ("szlMillimeters", SIZE),
    ]
#[repr(C)]
pub struct RECTL {
    pub left: i32,
    pub top: i32,
    pub right: i32,
    pub bottom: i32,
}

#[repr(C)]
pub struct SIZE {
    pub cx: i32,
    pub cy: i32,
}

#[repr(C)]
pub struct ENHMETAHEADER3 {
    pub iType: u32,
    pub nSize: u32,
    pub rclBounds: RECTL,
    pub rclFrame: RECTL,
    pub dSignature: u32,
    pub nVersion: u32,
    pub nBytes: u32,
    pub nRecords: u32,
    pub nHandles: u16,
    pub sReserved: u16,
    pub nDescription: u32,
    pub offDescription: u32,
    pub nPalEntries: u32,
    pub szlDevice: SIZE,
    pub szlMillimeters: SIZE,
}
import "golang.org/x/sys/windows"

type RECTL struct {
	left int32
	top int32
	right int32
	bottom int32
}

type SIZE struct {
	cx int32
	cy int32
}

type ENHMETAHEADER3 struct {
	iType uint32
	nSize uint32
	rclBounds RECTL
	rclFrame RECTL
	dSignature uint32
	nVersion uint32
	nBytes uint32
	nRecords uint32
	nHandles uint16
	sReserved uint16
	nDescription uint32
	offDescription uint32
	nPalEntries uint32
	szlDevice SIZE
	szlMillimeters SIZE
}
type
  RECTL = record
    left: Integer;
    top: Integer;
    right: Integer;
    bottom: Integer;
  end;

  SIZE = record
    cx: Integer;
    cy: Integer;
  end;

  ENHMETAHEADER3 = record
    iType: DWORD;
    nSize: DWORD;
    rclBounds: RECTL;
    rclFrame: RECTL;
    dSignature: DWORD;
    nVersion: DWORD;
    nBytes: DWORD;
    nRecords: DWORD;
    nHandles: Word;
    sReserved: Word;
    nDescription: DWORD;
    offDescription: DWORD;
    nPalEntries: DWORD;
    szlDevice: SIZE;
    szlMillimeters: SIZE;
  end;
const RECTL = extern struct {
    left: i32,
    top: i32,
    right: i32,
    bottom: i32,
};

const SIZE = extern struct {
    cx: i32,
    cy: i32,
};

const ENHMETAHEADER3 = extern struct {
    iType: u32,
    nSize: u32,
    rclBounds: RECTL,
    rclFrame: RECTL,
    dSignature: u32,
    nVersion: u32,
    nBytes: u32,
    nRecords: u32,
    nHandles: u16,
    sReserved: u16,
    nDescription: u32,
    offDescription: u32,
    nPalEntries: u32,
    szlDevice: SIZE,
    szlMillimeters: SIZE,
};
type
  RECTL {.bycopy.} = object
    left: int32
    top: int32
    right: int32
    bottom: int32

  SIZE {.bycopy.} = object
    cx: int32
    cy: int32

  ENHMETAHEADER3 {.bycopy.} = object
    iType: uint32
    nSize: uint32
    rclBounds: RECTL
    rclFrame: RECTL
    dSignature: uint32
    nVersion: uint32
    nBytes: uint32
    nRecords: uint32
    nHandles: uint16
    sReserved: uint16
    nDescription: uint32
    offDescription: uint32
    nPalEntries: uint32
    szlDevice: SIZE
    szlMillimeters: SIZE
struct RECTL
{
    int left;
    int top;
    int right;
    int bottom;
}

struct SIZE
{
    int cx;
    int cy;
}

struct ENHMETAHEADER3
{
    uint iType;
    uint nSize;
    RECTL rclBounds;
    RECTL rclFrame;
    uint dSignature;
    uint nVersion;
    uint nBytes;
    uint nRecords;
    ushort nHandles;
    ushort sReserved;
    uint nDescription;
    uint offDescription;
    uint nPalEntries;
    SIZE szlDevice;
    SIZE szlMillimeters;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; ENHMETAHEADER3 サイズ: 88 バイト(x64)
dim st, 22    ; 4byte整数×22(構造体サイズ 88 / 4 切り上げ)
; iType : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; nSize : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; rclBounds : RECTL (+8, 16byte)  varptr(st)+8 を基点に操作(16byte:入れ子/配列)
; rclFrame : RECTL (+24, 16byte)  varptr(st)+24 を基点に操作(16byte:入れ子/配列)
; dSignature : DWORD (+40, 4byte)  st.10 = 値  /  値 = st.10   (lpoke/lpeek も可)
; nVersion : DWORD (+44, 4byte)  st.11 = 値  /  値 = st.11   (lpoke/lpeek も可)
; nBytes : DWORD (+48, 4byte)  st.12 = 値  /  値 = st.12   (lpoke/lpeek も可)
; nRecords : DWORD (+52, 4byte)  st.13 = 値  /  値 = st.13   (lpoke/lpeek も可)
; nHandles : WORD (+56, 2byte)  wpoke st,56,値  /  値 = wpeek(st,56)
; sReserved : WORD (+58, 2byte)  wpoke st,58,値  /  値 = wpeek(st,58)
; nDescription : DWORD (+60, 4byte)  st.15 = 値  /  値 = st.15   (lpoke/lpeek も可)
; offDescription : DWORD (+64, 4byte)  st.16 = 値  /  値 = st.16   (lpoke/lpeek も可)
; nPalEntries : DWORD (+68, 4byte)  st.17 = 値  /  値 = st.17   (lpoke/lpeek も可)
; szlDevice : SIZE (+72, 8byte)  varptr(st)+72 を基点に操作(8byte:入れ子/配列)
; szlMillimeters : SIZE (+80, 8byte)  varptr(st)+80 を基点に操作(8byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global RECTL
    #field int left
    #field int top
    #field int right
    #field int bottom
#endstruct

#defstruct global SIZE
    #field int cx
    #field int cy
#endstruct

#defstruct global ENHMETAHEADER3
    #field int iType
    #field int nSize
    #field RECTL rclBounds
    #field RECTL rclFrame
    #field int dSignature
    #field int nVersion
    #field int nBytes
    #field int nRecords
    #field short nHandles
    #field short sReserved
    #field int nDescription
    #field int offDescription
    #field int nPalEntries
    #field SIZE szlDevice
    #field SIZE szlMillimeters
#endstruct

stdim st, ENHMETAHEADER3        ; NSTRUCT 変数を確保
st->iType = 100
mes "iType=" + st->iType