ホーム › UI.Controls.RichEdit › CHARFORMAT2A
CHARFORMAT2A
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 |
|---|---|---|---|---|
| Base | CHARFORMATA | 60 | +0 | +0 |
| wWeight | WORD | 2 | +60 | +60 |
| sSpacing | SHORT | 2 | +62 | +62 |
| crBackColor | COLORREF | 4 | +64 | +64 |
| lcid | DWORD | 4 | +68 | +68 |
| Anonymous | _Anonymous_e__Union | 4 | +72 | +72 |
| sStyle | SHORT | 2 | +76 | +76 |
| wKerning | WORD | 2 | +78 | +78 |
| bUnderlineType | BYTE | 1 | +80 | +80 |
| bAnimation | BYTE | 1 | +81 | +81 |
| bRevAuthor | BYTE | 1 | +82 | +82 |
| bUnderlineColor | BYTE | 1 | +83 | +83 |
共用体: _Anonymous_e__Union x64 4B / x86 4B
| フィールド | 型 | サイズ | x64 | x86 |
|---|---|---|---|---|
| dwReserved | DWORD | 4 | +0 | +0 |
| dwCookie | DWORD | 4 | +0 | +0 |
各言語での定義
#include <windows.h>
// CHARFORMATA (x64 60 / x86 60 バイト)
typedef struct CHARFORMATA {
DWORD cbSize;
CFM_MASK dwMask;
CFE_EFFECTS dwEffects;
INT yHeight;
INT yOffset;
COLORREF crTextColor;
FONT_CHARSET bCharSet;
BYTE bPitchAndFamily;
CHAR szFaceName[32];
} CHARFORMATA;
// CHARFORMAT2A (x64 84 / x86 84 バイト)
typedef struct CHARFORMAT2A {
CHARFORMATA Base;
WORD wWeight;
SHORT sSpacing;
COLORREF crBackColor;
DWORD lcid;
_Anonymous_e__Union Anonymous;
SHORT sStyle;
WORD wKerning;
BYTE bUnderlineType;
BYTE bAnimation;
BYTE bRevAuthor;
BYTE bUnderlineColor;
} CHARFORMAT2A;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CHARFORMATA
{
public uint cbSize;
public uint dwMask;
public uint dwEffects;
public int yHeight;
public int yOffset;
public uint crTextColor;
public byte bCharSet;
public byte bPitchAndFamily;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] public sbyte[] szFaceName;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CHARFORMAT2A
{
public CHARFORMATA Base;
public ushort wWeight;
public short sSpacing;
public uint crBackColor;
public uint lcid;
public _Anonymous_e__Union Anonymous;
public short sStyle;
public ushort wKerning;
public byte bUnderlineType;
public byte bAnimation;
public byte bRevAuthor;
public byte bUnderlineColor;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CHARFORMATA
Public cbSize As UInteger
Public dwMask As UInteger
Public dwEffects As UInteger
Public yHeight As Integer
Public yOffset As Integer
Public crTextColor As UInteger
Public bCharSet As Byte
Public bPitchAndFamily As Byte
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=32)> Public szFaceName() As SByte
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CHARFORMAT2A
Public Base As CHARFORMATA
Public wWeight As UShort
Public sSpacing As Short
Public crBackColor As UInteger
Public lcid As UInteger
Public Anonymous As _Anonymous_e__Union
Public sStyle As Short
Public wKerning As UShort
Public bUnderlineType As Byte
Public bAnimation As Byte
Public bRevAuthor As Byte
Public bUnderlineColor As Byte
End Structureimport ctypes
from ctypes import wintypes
class CHARFORMATA(ctypes.Structure):
_fields_ = [
("cbSize", wintypes.DWORD),
("dwMask", wintypes.DWORD),
("dwEffects", wintypes.DWORD),
("yHeight", ctypes.c_int),
("yOffset", ctypes.c_int),
("crTextColor", wintypes.DWORD),
("bCharSet", ctypes.c_ubyte),
("bPitchAndFamily", ctypes.c_ubyte),
("szFaceName", ctypes.c_byte * 32),
]
class CHARFORMAT2A(ctypes.Structure):
_fields_ = [
("Base", CHARFORMATA),
("wWeight", ctypes.c_ushort),
("sSpacing", ctypes.c_short),
("crBackColor", wintypes.DWORD),
("lcid", wintypes.DWORD),
("Anonymous", _Anonymous_e__Union),
("sStyle", ctypes.c_short),
("wKerning", ctypes.c_ushort),
("bUnderlineType", ctypes.c_ubyte),
("bAnimation", ctypes.c_ubyte),
("bRevAuthor", ctypes.c_ubyte),
("bUnderlineColor", ctypes.c_ubyte),
]#[repr(C)]
pub struct CHARFORMATA {
pub cbSize: u32,
pub dwMask: u32,
pub dwEffects: u32,
pub yHeight: i32,
pub yOffset: i32,
pub crTextColor: u32,
pub bCharSet: u8,
pub bPitchAndFamily: u8,
pub szFaceName: [i8; 32],
}
#[repr(C)]
pub struct CHARFORMAT2A {
pub Base: CHARFORMATA,
pub wWeight: u16,
pub sSpacing: i16,
pub crBackColor: u32,
pub lcid: u32,
pub Anonymous: _Anonymous_e__Union,
pub sStyle: i16,
pub wKerning: u16,
pub bUnderlineType: u8,
pub bAnimation: u8,
pub bRevAuthor: u8,
pub bUnderlineColor: u8,
}import "golang.org/x/sys/windows"
type CHARFORMATA struct {
cbSize uint32
dwMask uint32
dwEffects uint32
yHeight int32
yOffset int32
crTextColor uint32
bCharSet byte
bPitchAndFamily byte
szFaceName [32]int8
}
type CHARFORMAT2A struct {
Base CHARFORMATA
wWeight uint16
sSpacing int16
crBackColor uint32
lcid uint32
Anonymous _Anonymous_e__Union
sStyle int16
wKerning uint16
bUnderlineType byte
bAnimation byte
bRevAuthor byte
bUnderlineColor byte
}type
CHARFORMATA = record
cbSize: DWORD;
dwMask: DWORD;
dwEffects: DWORD;
yHeight: Integer;
yOffset: Integer;
crTextColor: DWORD;
bCharSet: Byte;
bPitchAndFamily: Byte;
szFaceName: array[0..31] of Shortint;
end;
CHARFORMAT2A = record
Base: CHARFORMATA;
wWeight: Word;
sSpacing: Smallint;
crBackColor: DWORD;
lcid: DWORD;
Anonymous: _Anonymous_e__Union;
sStyle: Smallint;
wKerning: Word;
bUnderlineType: Byte;
bAnimation: Byte;
bRevAuthor: Byte;
bUnderlineColor: Byte;
end;const CHARFORMATA = extern struct {
cbSize: u32,
dwMask: u32,
dwEffects: u32,
yHeight: i32,
yOffset: i32,
crTextColor: u32,
bCharSet: u8,
bPitchAndFamily: u8,
szFaceName: [32]i8,
};
const CHARFORMAT2A = extern struct {
Base: CHARFORMATA,
wWeight: u16,
sSpacing: i16,
crBackColor: u32,
lcid: u32,
Anonymous: _Anonymous_e__Union,
sStyle: i16,
wKerning: u16,
bUnderlineType: u8,
bAnimation: u8,
bRevAuthor: u8,
bUnderlineColor: u8,
};type
CHARFORMATA {.bycopy.} = object
cbSize: uint32
dwMask: uint32
dwEffects: uint32
yHeight: int32
yOffset: int32
crTextColor: uint32
bCharSet: uint8
bPitchAndFamily: uint8
szFaceName: array[32, int8]
CHARFORMAT2A {.bycopy.} = object
Base: CHARFORMATA
wWeight: uint16
sSpacing: int16
crBackColor: uint32
lcid: uint32
Anonymous: _Anonymous_e__Union
sStyle: int16
wKerning: uint16
bUnderlineType: uint8
bAnimation: uint8
bRevAuthor: uint8
bUnderlineColor: uint8struct CHARFORMATA
{
uint cbSize;
uint dwMask;
uint dwEffects;
int yHeight;
int yOffset;
uint crTextColor;
ubyte bCharSet;
ubyte bPitchAndFamily;
byte[32] szFaceName;
}
struct CHARFORMAT2A
{
CHARFORMATA Base;
ushort wWeight;
short sSpacing;
uint crBackColor;
uint lcid;
_Anonymous_e__Union Anonymous;
short sStyle;
ushort wKerning;
ubyte bUnderlineType;
ubyte bAnimation;
ubyte bRevAuthor;
ubyte bUnderlineColor;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; CHARFORMAT2A サイズ: 84 バイト(x64)
dim st, 21 ; 4byte整数×21(構造体サイズ 84 / 4 切り上げ)
; Base : CHARFORMATA (+0, 60byte) varptr(st)+0 を基点に操作(60byte:入れ子/配列)
; wWeight : WORD (+60, 2byte) wpoke st,60,値 / 値 = wpeek(st,60)
; sSpacing : SHORT (+62, 2byte) wpoke st,62,値 / 値 = wpeek(st,62)
; crBackColor : COLORREF (+64, 4byte) st.16 = 値 / 値 = st.16 (lpoke/lpeek も可)
; lcid : DWORD (+68, 4byte) st.17 = 値 / 値 = st.17 (lpoke/lpeek も可)
; Anonymous : _Anonymous_e__Union (+72, 4byte) varptr(st)+72 を基点に操作(4byte:入れ子/配列)
; sStyle : SHORT (+76, 2byte) wpoke st,76,値 / 値 = wpeek(st,76)
; wKerning : WORD (+78, 2byte) wpoke st,78,値 / 値 = wpeek(st,78)
; bUnderlineType : BYTE (+80, 1byte) poke st,80,値 / 値 = peek(st,80)
; bAnimation : BYTE (+81, 1byte) poke st,81,値 / 値 = peek(st,81)
; bRevAuthor : BYTE (+82, 1byte) poke st,82,値 / 値 = peek(st,82)
; bUnderlineColor : BYTE (+83, 1byte) poke st,83,値 / 値 = peek(st,83)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global CHARFORMATA
#field int cbSize
#field int dwMask
#field int dwEffects
#field int yHeight
#field int yOffset
#field int crTextColor
#field byte bCharSet
#field byte bPitchAndFamily
#field byte szFaceName 32
#endstruct
#defstruct global CHARFORMAT2A
#field CHARFORMATA Base
#field short wWeight
#field short sSpacing
#field int crBackColor
#field int lcid
#field byte Anonymous 4
#field short sStyle
#field short wKerning
#field byte bUnderlineType
#field byte bAnimation
#field byte bRevAuthor
#field byte bUnderlineColor
#endstruct
stdim st, CHARFORMAT2A ; NSTRUCT 変数を確保
st->wWeight = 100
mes "wWeight=" + st->wWeight
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。