Win32 API 日本語リファレンス
ホームUI.Controls.RichEdit › CHARFORMATW

CHARFORMATW

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

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

フィールド

フィールドサイズx64x86
cbSizeDWORD4+0+0
dwMaskCFM_MASK4+4+4
dwEffectsCFE_EFFECTS4+8+8
yHeightINT4+12+12
yOffsetINT4+16+16
crTextColorCOLORREF4+20+20
bCharSetFONT_CHARSET1+24+24
bPitchAndFamilyBYTE1+25+25
szFaceNameWCHAR64+26+26

各言語での定義

#include <windows.h>

// CHARFORMATW  (x64 92 / x86 92 バイト)
typedef struct CHARFORMATW {
    DWORD cbSize;
    CFM_MASK dwMask;
    CFE_EFFECTS dwEffects;
    INT yHeight;
    INT yOffset;
    COLORREF crTextColor;
    FONT_CHARSET bCharSet;
    BYTE bPitchAndFamily;
    WCHAR szFaceName[32];
} CHARFORMATW;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CHARFORMATW
{
    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.ByValTStr, SizeConst = 32)] public string szFaceName;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CHARFORMATW
    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.ByValTStr, SizeConst:=32)> Public szFaceName As String
End Structure
import ctypes
from ctypes import wintypes

class CHARFORMATW(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_wchar * 32),
    ]
#[repr(C)]
pub struct CHARFORMATW {
    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: [u16; 32],
}
import "golang.org/x/sys/windows"

type CHARFORMATW struct {
	cbSize uint32
	dwMask uint32
	dwEffects uint32
	yHeight int32
	yOffset int32
	crTextColor uint32
	bCharSet byte
	bPitchAndFamily byte
	szFaceName [32]uint16
}
type
  CHARFORMATW = record
    cbSize: DWORD;
    dwMask: DWORD;
    dwEffects: DWORD;
    yHeight: Integer;
    yOffset: Integer;
    crTextColor: DWORD;
    bCharSet: Byte;
    bPitchAndFamily: Byte;
    szFaceName: array[0..31] of WideChar;
  end;
const CHARFORMATW = extern struct {
    cbSize: u32,
    dwMask: u32,
    dwEffects: u32,
    yHeight: i32,
    yOffset: i32,
    crTextColor: u32,
    bCharSet: u8,
    bPitchAndFamily: u8,
    szFaceName: [32]u16,
};
type
  CHARFORMATW {.bycopy.} = object
    cbSize: uint32
    dwMask: uint32
    dwEffects: uint32
    yHeight: int32
    yOffset: int32
    crTextColor: uint32
    bCharSet: uint8
    bPitchAndFamily: uint8
    szFaceName: array[32, uint16]
struct CHARFORMATW
{
    uint cbSize;
    uint dwMask;
    uint dwEffects;
    int yHeight;
    int yOffset;
    uint crTextColor;
    ubyte bCharSet;
    ubyte bPitchAndFamily;
    wchar[32] szFaceName;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; CHARFORMATW サイズ: 92 バイト(x64)
dim st, 23    ; 4byte整数×23(構造体サイズ 92 / 4 切り上げ)
; cbSize : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; dwMask : CFM_MASK (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; dwEffects : CFE_EFFECTS (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; yHeight : INT (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; yOffset : INT (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; crTextColor : COLORREF (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; bCharSet : FONT_CHARSET (+24, 1byte)  poke st,24,値  /  値 = peek(st,24)
; bPitchAndFamily : BYTE (+25, 1byte)  poke st,25,値  /  値 = peek(st,25)
; szFaceName : WCHAR (+26, 64byte)  varptr(st)+26 を基点に操作(64byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global CHARFORMATW
    #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 wchar szFaceName 32
#endstruct

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