Win32 API 日本語リファレンス
ホームUI.TextServices › TF_DISPLAYATTRIBUTE

TF_DISPLAYATTRIBUTE

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

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

フィールド

フィールドサイズx64x86説明
crTextTF_DA_COLOR8+0+0テキストの前景色(TF_DA_COLOR)。
crBkTF_DA_COLOR8+8+8テキストの背景色(TF_DA_COLOR)。
lsStyleTF_DA_LINESTYLE4+16+16下線のスタイルを示す TF_DA_LINESTYLE。
fBoldLineBOOL4+20+20下線を太線で描画するかどうかを示す真偽値。
crLineTF_DA_COLOR8+24+24下線の色(TF_DA_COLOR)。
bAttrTF_DA_ATTR_INFO4+32+32変換状態(入力中・変換済み等)を示す TF_DA_ATTR_INFO。

各言語での定義

#include <windows.h>

// TF_DA_COLOR  (x64 8 / x86 8 バイト)
typedef struct TF_DA_COLOR {
    TF_DA_COLORTYPE type;
    _Anonymous_e__Union Anonymous;
} TF_DA_COLOR;

// TF_DISPLAYATTRIBUTE  (x64 36 / x86 36 バイト)
typedef struct TF_DISPLAYATTRIBUTE {
    TF_DA_COLOR crText;
    TF_DA_COLOR crBk;
    TF_DA_LINESTYLE lsStyle;
    BOOL fBoldLine;
    TF_DA_COLOR crLine;
    TF_DA_ATTR_INFO bAttr;
} TF_DISPLAYATTRIBUTE;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct TF_DA_COLOR
{
    public int type;
    public _Anonymous_e__Union Anonymous;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct TF_DISPLAYATTRIBUTE
{
    public TF_DA_COLOR crText;
    public TF_DA_COLOR crBk;
    public int lsStyle;
    [MarshalAs(UnmanagedType.Bool)] public bool fBoldLine;
    public TF_DA_COLOR crLine;
    public int bAttr;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure TF_DA_COLOR
    Public type As Integer
    Public Anonymous As _Anonymous_e__Union
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure TF_DISPLAYATTRIBUTE
    Public crText As TF_DA_COLOR
    Public crBk As TF_DA_COLOR
    Public lsStyle As Integer
    <MarshalAs(UnmanagedType.Bool)> Public fBoldLine As Boolean
    Public crLine As TF_DA_COLOR
    Public bAttr As Integer
End Structure
import ctypes
from ctypes import wintypes

class TF_DA_COLOR(ctypes.Structure):
    _fields_ = [
        ("type", ctypes.c_int),
        ("Anonymous", _Anonymous_e__Union),
    ]

class TF_DISPLAYATTRIBUTE(ctypes.Structure):
    _fields_ = [
        ("crText", TF_DA_COLOR),
        ("crBk", TF_DA_COLOR),
        ("lsStyle", ctypes.c_int),
        ("fBoldLine", wintypes.BOOL),
        ("crLine", TF_DA_COLOR),
        ("bAttr", ctypes.c_int),
    ]
#[repr(C)]
pub struct TF_DA_COLOR {
    pub type: i32,
    pub Anonymous: _Anonymous_e__Union,
}

#[repr(C)]
pub struct TF_DISPLAYATTRIBUTE {
    pub crText: TF_DA_COLOR,
    pub crBk: TF_DA_COLOR,
    pub lsStyle: i32,
    pub fBoldLine: i32,
    pub crLine: TF_DA_COLOR,
    pub bAttr: i32,
}
import "golang.org/x/sys/windows"

type TF_DA_COLOR struct {
	type int32
	Anonymous _Anonymous_e__Union
}

type TF_DISPLAYATTRIBUTE struct {
	crText TF_DA_COLOR
	crBk TF_DA_COLOR
	lsStyle int32
	fBoldLine int32
	crLine TF_DA_COLOR
	bAttr int32
}
type
  TF_DA_COLOR = record
    type: Integer;
    Anonymous: _Anonymous_e__Union;
  end;

  TF_DISPLAYATTRIBUTE = record
    crText: TF_DA_COLOR;
    crBk: TF_DA_COLOR;
    lsStyle: Integer;
    fBoldLine: BOOL;
    crLine: TF_DA_COLOR;
    bAttr: Integer;
  end;
const TF_DA_COLOR = extern struct {
    type: i32,
    Anonymous: _Anonymous_e__Union,
};

const TF_DISPLAYATTRIBUTE = extern struct {
    crText: TF_DA_COLOR,
    crBk: TF_DA_COLOR,
    lsStyle: i32,
    fBoldLine: i32,
    crLine: TF_DA_COLOR,
    bAttr: i32,
};
type
  TF_DA_COLOR {.bycopy.} = object
    type: int32
    Anonymous: _Anonymous_e__Union

  TF_DISPLAYATTRIBUTE {.bycopy.} = object
    crText: TF_DA_COLOR
    crBk: TF_DA_COLOR
    lsStyle: int32
    fBoldLine: int32
    crLine: TF_DA_COLOR
    bAttr: int32
struct TF_DA_COLOR
{
    int type;
    _Anonymous_e__Union Anonymous;
}

struct TF_DISPLAYATTRIBUTE
{
    TF_DA_COLOR crText;
    TF_DA_COLOR crBk;
    int lsStyle;
    int fBoldLine;
    TF_DA_COLOR crLine;
    int bAttr;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; TF_DISPLAYATTRIBUTE サイズ: 36 バイト(x64)
dim st, 9    ; 4byte整数×9(構造体サイズ 36 / 4 切り上げ)
; crText : TF_DA_COLOR (+0, 8byte)  varptr(st)+0 を基点に操作(8byte:入れ子/配列)
; crBk : TF_DA_COLOR (+8, 8byte)  varptr(st)+8 を基点に操作(8byte:入れ子/配列)
; lsStyle : TF_DA_LINESTYLE (+16, 4byte)  st.4 = 値  /  値 = st.4   (lpoke/lpeek も可)
; fBoldLine : BOOL (+20, 4byte)  st.5 = 値  /  値 = st.5   (lpoke/lpeek も可)
; crLine : TF_DA_COLOR (+24, 8byte)  varptr(st)+24 を基点に操作(8byte:入れ子/配列)
; bAttr : TF_DA_ATTR_INFO (+32, 4byte)  st.8 = 値  /  値 = st.8   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global TF_DA_COLOR
    #field int type
    #field byte Anonymous 4
#endstruct

#defstruct global TF_DISPLAYATTRIBUTE
    #field TF_DA_COLOR crText
    #field TF_DA_COLOR crBk
    #field int lsStyle
    #field bool fBoldLine
    #field TF_DA_COLOR crLine
    #field int bAttr
#endstruct

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