ホーム › Graphics.Gdi › EMRCREATEBRUSHINDIRECT
EMRCREATEBRUSHINDIRECT
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| emr | EMR | 8 | +0 | +0 | 共通レコードヘッダを表すEMR構造体。 |
| ihBrush | DWORD | 4 | +8 | +8 | 作成するブラシのハンドルテーブル内インデックスを表す。 |
| lb | LOGBRUSH32 | 12 | +12 | +12 | 作成する論理ブラシを表すLOGBRUSH32構造体。 |
各言語での定義
#include <windows.h>
// EMR (x64 8 / x86 8 バイト)
typedef struct EMR {
ENHANCED_METAFILE_RECORD_TYPE iType;
DWORD nSize;
} EMR;
// LOGBRUSH32 (x64 12 / x86 12 バイト)
typedef struct LOGBRUSH32 {
BRUSH_STYLE lbStyle;
COLORREF lbColor;
DWORD lbHatch;
} LOGBRUSH32;
// EMRCREATEBRUSHINDIRECT (x64 24 / x86 24 バイト)
typedef struct EMRCREATEBRUSHINDIRECT {
EMR emr;
DWORD ihBrush;
LOGBRUSH32 lb;
} EMRCREATEBRUSHINDIRECT;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 LOGBRUSH32
{
public uint lbStyle;
public uint lbColor;
public uint lbHatch;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct EMRCREATEBRUSHINDIRECT
{
public EMR emr;
public uint ihBrush;
public LOGBRUSH32 lb;
}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 LOGBRUSH32
Public lbStyle As UInteger
Public lbColor As UInteger
Public lbHatch As UInteger
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure EMRCREATEBRUSHINDIRECT
Public emr As EMR
Public ihBrush As UInteger
Public lb As LOGBRUSH32
End Structureimport ctypes
from ctypes import wintypes
class EMR(ctypes.Structure):
_fields_ = [
("iType", wintypes.DWORD),
("nSize", wintypes.DWORD),
]
class LOGBRUSH32(ctypes.Structure):
_fields_ = [
("lbStyle", wintypes.DWORD),
("lbColor", wintypes.DWORD),
("lbHatch", wintypes.DWORD),
]
class EMRCREATEBRUSHINDIRECT(ctypes.Structure):
_fields_ = [
("emr", EMR),
("ihBrush", wintypes.DWORD),
("lb", LOGBRUSH32),
]#[repr(C)]
pub struct EMR {
pub iType: u32,
pub nSize: u32,
}
#[repr(C)]
pub struct LOGBRUSH32 {
pub lbStyle: u32,
pub lbColor: u32,
pub lbHatch: u32,
}
#[repr(C)]
pub struct EMRCREATEBRUSHINDIRECT {
pub emr: EMR,
pub ihBrush: u32,
pub lb: LOGBRUSH32,
}import "golang.org/x/sys/windows"
type EMR struct {
iType uint32
nSize uint32
}
type LOGBRUSH32 struct {
lbStyle uint32
lbColor uint32
lbHatch uint32
}
type EMRCREATEBRUSHINDIRECT struct {
emr EMR
ihBrush uint32
lb LOGBRUSH32
}type
EMR = record
iType: DWORD;
nSize: DWORD;
end;
LOGBRUSH32 = record
lbStyle: DWORD;
lbColor: DWORD;
lbHatch: DWORD;
end;
EMRCREATEBRUSHINDIRECT = record
emr: EMR;
ihBrush: DWORD;
lb: LOGBRUSH32;
end;const EMR = extern struct {
iType: u32,
nSize: u32,
};
const LOGBRUSH32 = extern struct {
lbStyle: u32,
lbColor: u32,
lbHatch: u32,
};
const EMRCREATEBRUSHINDIRECT = extern struct {
emr: EMR,
ihBrush: u32,
lb: LOGBRUSH32,
};type
EMR {.bycopy.} = object
iType: uint32
nSize: uint32
LOGBRUSH32 {.bycopy.} = object
lbStyle: uint32
lbColor: uint32
lbHatch: uint32
EMRCREATEBRUSHINDIRECT {.bycopy.} = object
emr: EMR
ihBrush: uint32
lb: LOGBRUSH32struct EMR
{
uint iType;
uint nSize;
}
struct LOGBRUSH32
{
uint lbStyle;
uint lbColor;
uint lbHatch;
}
struct EMRCREATEBRUSHINDIRECT
{
EMR emr;
uint ihBrush;
LOGBRUSH32 lb;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; EMRCREATEBRUSHINDIRECT サイズ: 24 バイト(x64)
dim st, 6 ; 4byte整数×6(構造体サイズ 24 / 4 切り上げ)
; emr : EMR (+0, 8byte) varptr(st)+0 を基点に操作(8byte:入れ子/配列)
; ihBrush : DWORD (+8, 4byte) st.2 = 値 / 値 = st.2 (lpoke/lpeek も可)
; lb : LOGBRUSH32 (+12, 12byte) varptr(st)+12 を基点に操作(12byte:入れ子/配列)
; ※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 LOGBRUSH32
#field int lbStyle
#field int lbColor
#field int lbHatch
#endstruct
#defstruct global EMRCREATEBRUSHINDIRECT
#field EMR emr
#field int ihBrush
#field LOGBRUSH32 lb
#endstruct
stdim st, EMRCREATEBRUSHINDIRECT ; NSTRUCT 変数を確保
st->ihBrush = 100
mes "ihBrush=" + st->ihBrush