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

WmfPlaceableFileHeader

構造体
サイズx64: 22 バイト / x86: 22 バイトパッキング2

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

フィールド

フィールドサイズx64x86説明
KeyDWORD4+0+0配置可能メタファイルを識別するマジックナンバー(0x9AC6CDD7)を表す。
HmfSHORT2+4+4メタファイルハンドル。常に0でなければならない。
BoundingBoxPWMFRect168+6+6メタファイルの境界矩形を表すPWMFRect16構造体。
InchSHORT2+14+141論理インチあたりの単位数を表す。
ReservedDWORD4+16+16予約済みフィールド。0でなければならない。
ChecksumSHORT2+20+20ヘッダ先頭10ワードのXORによるチェックサムを表す。

各言語での定義

#include <windows.h>

// PWMFRect16  (x64 8 / x86 8 バイト)
typedef struct PWMFRect16 {
    SHORT Left;
    SHORT Top;
    SHORT Right;
    SHORT Bottom;
} PWMFRect16;

// WmfPlaceableFileHeader  (x64 22 / x86 22 バイト)
#pragma pack(push, 2)
typedef struct WmfPlaceableFileHeader {
    DWORD Key;
    SHORT Hmf;
    PWMFRect16 BoundingBox;
    SHORT Inch;
    DWORD Reserved;
    SHORT Checksum;
} WmfPlaceableFileHeader;
#pragma pack(pop)
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct PWMFRect16
{
    public short Left;
    public short Top;
    public short Right;
    public short Bottom;
}

[StructLayout(LayoutKind.Sequential, Pack = 2, CharSet = CharSet.Unicode)]
public struct WmfPlaceableFileHeader
{
    public uint Key;
    public short Hmf;
    public PWMFRect16 BoundingBox;
    public short Inch;
    public uint Reserved;
    public short Checksum;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure PWMFRect16
    Public Left As Short
    Public Top As Short
    Public Right As Short
    Public Bottom As Short
End Structure

<StructLayout(LayoutKind.Sequential, Pack:=2, CharSet:=CharSet.Unicode)>
Public Structure WmfPlaceableFileHeader
    Public Key As UInteger
    Public Hmf As Short
    Public BoundingBox As PWMFRect16
    Public Inch As Short
    Public Reserved As UInteger
    Public Checksum As Short
End Structure
import ctypes
from ctypes import wintypes

class PWMFRect16(ctypes.Structure):
    _fields_ = [
        ("Left", ctypes.c_short),
        ("Top", ctypes.c_short),
        ("Right", ctypes.c_short),
        ("Bottom", ctypes.c_short),
    ]

class WmfPlaceableFileHeader(ctypes.Structure):
    _pack_ = 2
    _fields_ = [
        ("Key", wintypes.DWORD),
        ("Hmf", ctypes.c_short),
        ("BoundingBox", PWMFRect16),
        ("Inch", ctypes.c_short),
        ("Reserved", wintypes.DWORD),
        ("Checksum", ctypes.c_short),
    ]
#[repr(C)]
pub struct PWMFRect16 {
    pub Left: i16,
    pub Top: i16,
    pub Right: i16,
    pub Bottom: i16,
}

#[repr(C, packed(2))]
pub struct WmfPlaceableFileHeader {
    pub Key: u32,
    pub Hmf: i16,
    pub BoundingBox: PWMFRect16,
    pub Inch: i16,
    pub Reserved: u32,
    pub Checksum: i16,
}
import "golang.org/x/sys/windows"

type PWMFRect16 struct {
	Left int16
	Top int16
	Right int16
	Bottom int16
}

type WmfPlaceableFileHeader struct {
	Key uint32
	Hmf int16
	BoundingBox PWMFRect16
	Inch int16
	Reserved uint32
	Checksum int16
}
type
  PWMFRect16 = record
    Left: Smallint;
    Top: Smallint;
    Right: Smallint;
    Bottom: Smallint;
  end;

  WmfPlaceableFileHeader = packed record
    Key: DWORD;
    Hmf: Smallint;
    BoundingBox: PWMFRect16;
    Inch: Smallint;
    Reserved: DWORD;
    Checksum: Smallint;
  end;
const PWMFRect16 = extern struct {
    Left: i16,
    Top: i16,
    Right: i16,
    Bottom: i16,
};

const WmfPlaceableFileHeader = extern struct {
    Key: u32,
    Hmf: i16,
    BoundingBox: PWMFRect16,
    Inch: i16,
    Reserved: u32,
    Checksum: i16,
};
type
  PWMFRect16 {.bycopy.} = object
    Left: int16
    Top: int16
    Right: int16
    Bottom: int16

  WmfPlaceableFileHeader {.packed.} = object
    Key: uint32
    Hmf: int16
    BoundingBox: PWMFRect16
    Inch: int16
    Reserved: uint32
    Checksum: int16
struct PWMFRect16
{
    short Left;
    short Top;
    short Right;
    short Bottom;
}

align(2)
struct WmfPlaceableFileHeader
{
    uint Key;
    short Hmf;
    PWMFRect16 BoundingBox;
    short Inch;
    uint Reserved;
    short Checksum;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; WmfPlaceableFileHeader サイズ: 22 バイト(x64)
dim st, 6    ; 4byte整数×6(構造体サイズ 22 / 4 切り上げ)
; Key : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; Hmf : SHORT (+4, 2byte)  wpoke st,4,値  /  値 = wpeek(st,4)
; BoundingBox : PWMFRect16 (+6, 8byte)  varptr(st)+6 を基点に操作(8byte:入れ子/配列)
; Inch : SHORT (+14, 2byte)  wpoke st,14,値  /  値 = wpeek(st,14)
; Reserved : DWORD (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; Checksum : SHORT (+20, 2byte)  wpoke st,20,値  /  値 = wpeek(st,20)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global PWMFRect16
    #field short Left
    #field short Top
    #field short Right
    #field short Bottom
#endstruct

#defstruct global WmfPlaceableFileHeader, pack=2
    #field int Key
    #field short Hmf
    #field PWMFRect16 BoundingBox
    #field short Inch
    #field int Reserved
    #field short Checksum
#endstruct

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