ホーム › Graphics.Gdi › EMRCREATEPEN
EMRCREATEPEN
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| emr | EMR | 8 | +0 | +0 | 共通レコードヘッダを表すEMR構造体。 |
| ihPen | DWORD | 4 | +8 | +8 | 作成するペンのハンドルテーブル内インデックスを表す。 |
| lopn | LOGPEN | 16 | +12 | +12 | 作成する論理ペンを表すLOGPEN構造体。 |
各言語での定義
#include <windows.h>
// EMR (x64 8 / x86 8 バイト)
typedef struct EMR {
ENHANCED_METAFILE_RECORD_TYPE iType;
DWORD nSize;
} EMR;
// POINT (x64 8 / x86 8 バイト)
typedef struct POINT {
INT x;
INT y;
} POINT;
// LOGPEN (x64 16 / x86 16 バイト)
typedef struct LOGPEN {
DWORD lopnStyle;
POINT lopnWidth;
COLORREF lopnColor;
} LOGPEN;
// EMRCREATEPEN (x64 28 / x86 28 バイト)
typedef struct EMRCREATEPEN {
EMR emr;
DWORD ihPen;
LOGPEN lopn;
} EMRCREATEPEN;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct EMR
{
public uint iType;
public uint nSize;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct POINT
{
public int x;
public int y;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct LOGPEN
{
public uint lopnStyle;
public POINT lopnWidth;
public uint lopnColor;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct EMRCREATEPEN
{
public EMR emr;
public uint ihPen;
public LOGPEN lopn;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure EMR
Public iType As UInteger
Public nSize As UInteger
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure POINT
Public x As Integer
Public y As Integer
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure LOGPEN
Public lopnStyle As UInteger
Public lopnWidth As POINT
Public lopnColor As UInteger
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure EMRCREATEPEN
Public emr As EMR
Public ihPen As UInteger
Public lopn As LOGPEN
End Structureimport ctypes
from ctypes import wintypes
class EMR(ctypes.Structure):
_fields_ = [
("iType", wintypes.DWORD),
("nSize", wintypes.DWORD),
]
class POINT(ctypes.Structure):
_fields_ = [
("x", ctypes.c_int),
("y", ctypes.c_int),
]
class LOGPEN(ctypes.Structure):
_fields_ = [
("lopnStyle", wintypes.DWORD),
("lopnWidth", POINT),
("lopnColor", wintypes.DWORD),
]
class EMRCREATEPEN(ctypes.Structure):
_fields_ = [
("emr", EMR),
("ihPen", wintypes.DWORD),
("lopn", LOGPEN),
]#[repr(C)]
pub struct EMR {
pub iType: u32,
pub nSize: u32,
}
#[repr(C)]
pub struct POINT {
pub x: i32,
pub y: i32,
}
#[repr(C)]
pub struct LOGPEN {
pub lopnStyle: u32,
pub lopnWidth: POINT,
pub lopnColor: u32,
}
#[repr(C)]
pub struct EMRCREATEPEN {
pub emr: EMR,
pub ihPen: u32,
pub lopn: LOGPEN,
}import "golang.org/x/sys/windows"
type EMR struct {
iType uint32
nSize uint32
}
type POINT struct {
x int32
y int32
}
type LOGPEN struct {
lopnStyle uint32
lopnWidth POINT
lopnColor uint32
}
type EMRCREATEPEN struct {
emr EMR
ihPen uint32
lopn LOGPEN
}type
EMR = record
iType: DWORD;
nSize: DWORD;
end;
POINT = record
x: Integer;
y: Integer;
end;
LOGPEN = record
lopnStyle: DWORD;
lopnWidth: POINT;
lopnColor: DWORD;
end;
EMRCREATEPEN = record
emr: EMR;
ihPen: DWORD;
lopn: LOGPEN;
end;const EMR = extern struct {
iType: u32,
nSize: u32,
};
const POINT = extern struct {
x: i32,
y: i32,
};
const LOGPEN = extern struct {
lopnStyle: u32,
lopnWidth: POINT,
lopnColor: u32,
};
const EMRCREATEPEN = extern struct {
emr: EMR,
ihPen: u32,
lopn: LOGPEN,
};type
EMR {.bycopy.} = object
iType: uint32
nSize: uint32
POINT {.bycopy.} = object
x: int32
y: int32
LOGPEN {.bycopy.} = object
lopnStyle: uint32
lopnWidth: POINT
lopnColor: uint32
EMRCREATEPEN {.bycopy.} = object
emr: EMR
ihPen: uint32
lopn: LOGPENstruct EMR
{
uint iType;
uint nSize;
}
struct POINT
{
int x;
int y;
}
struct LOGPEN
{
uint lopnStyle;
POINT lopnWidth;
uint lopnColor;
}
struct EMRCREATEPEN
{
EMR emr;
uint ihPen;
LOGPEN lopn;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; EMRCREATEPEN サイズ: 28 バイト(x64)
dim st, 7 ; 4byte整数×7(構造体サイズ 28 / 4 切り上げ)
; emr : EMR (+0, 8byte) varptr(st)+0 を基点に操作(8byte:入れ子/配列)
; ihPen : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; lopn : LOGPEN (+12, 16byte) varptr(st)+12 を基点に操作(16byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global EMR
#field int iType
#field int nSize
#endstruct
#defstruct global POINT
#field int x
#field int y
#endstruct
#defstruct global LOGPEN
#field int lopnStyle
#field POINT lopnWidth
#field int lopnColor
#endstruct
#defstruct global EMRCREATEPEN
#field EMR emr
#field int ihPen
#field LOGPEN lopn
#endstruct
stdim st, EMRCREATEPEN ; NSTRUCT 変数を確保
st->ihPen = 100
mes "ihPen=" + st->ihPen