Win32 API 日本語リファレンス
ホームDevices.Display › VGA_CHAR

VGA_CHAR

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

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

フィールド

フィールドサイズx64x86説明
CharCHAR1+0+0表示する文字コード(1バイト)。
AttributesCHAR1+1+1文字の表示属性(前景色/背景色)バイト。

各言語での定義

#include <windows.h>

// VGA_CHAR  (x64 2 / x86 2 バイト)
typedef struct VGA_CHAR {
    CHAR Char;
    CHAR Attributes;
} VGA_CHAR;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct VGA_CHAR
{
    public sbyte Char;
    public sbyte Attributes;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure VGA_CHAR
    Public Char As SByte
    Public Attributes As SByte
End Structure
import ctypes
from ctypes import wintypes

class VGA_CHAR(ctypes.Structure):
    _fields_ = [
        ("Char", ctypes.c_byte),
        ("Attributes", ctypes.c_byte),
    ]
#[repr(C)]
pub struct VGA_CHAR {
    pub Char: i8,
    pub Attributes: i8,
}
import "golang.org/x/sys/windows"

type VGA_CHAR struct {
	Char int8
	Attributes int8
}
type
  VGA_CHAR = record
    Char: Shortint;
    Attributes: Shortint;
  end;
const VGA_CHAR = extern struct {
    Char: i8,
    Attributes: i8,
};
type
  VGA_CHAR {.bycopy.} = object
    Char: int8
    Attributes: int8
struct VGA_CHAR
{
    byte Char;
    byte Attributes;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; VGA_CHAR サイズ: 2 バイト(x64)
dim st, 1    ; 4byte整数×1(構造体サイズ 2 / 4 切り上げ)
; Char : CHAR (+0, 1byte)  poke st,0,値  /  値 = peek(st,0)
; Attributes : CHAR (+1, 1byte)  poke st,1,値  /  値 = peek(st,1)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global VGA_CHAR
    #field byte Char
    #field byte Attributes
#endstruct

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