ホーム › System.Console › CONSOLE_SCREEN_BUFFER_INFOEX
CONSOLE_SCREEN_BUFFER_INFOEX
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| cbSize | DWORD | 4 | +0 | +0 | この構造体のバイトサイズ。呼び出し前に設定する。 |
| dwSize | COORD | 4 | +4 | +4 | スクリーンバッファのサイズ(COORD)。 |
| dwCursorPosition | COORD | 4 | +8 | +8 | 現在のカーソル位置(COORD)。 |
| wAttributes | CONSOLE_CHARACTER_ATTRIBUTES | 2 | +12 | +12 | 現在の文字色属性(CONSOLE_CHARACTER_ATTRIBUTES)。 |
| srWindow | SMALL_RECT | 8 | +14 | +14 | 表示中のウィンドウ領域を示す矩形(SMALL_RECT)。 |
| dwMaximumWindowSize | COORD | 4 | +22 | +22 | 可能な最大ウィンドウサイズ(COORD)。 |
| wPopupAttributes | WORD | 2 | +26 | +26 | ポップアップ表示時の文字色属性。 |
| bFullscreenSupported | BOOL | 4 | +28 | +28 | 全画面表示がサポートされているかを示すフラグ。 |
| ColorTable | COLORREF | 64 | +32 | +32 | 16色のカラーパレットを定義するCOLORREF配列。 |
各言語での定義
#include <windows.h>
// COORD (x64 4 / x86 4 バイト)
typedef struct COORD {
SHORT X;
SHORT Y;
} COORD;
// SMALL_RECT (x64 8 / x86 8 バイト)
typedef struct SMALL_RECT {
SHORT Left;
SHORT Top;
SHORT Right;
SHORT Bottom;
} SMALL_RECT;
// CONSOLE_SCREEN_BUFFER_INFOEX (x64 96 / x86 96 バイト)
typedef struct CONSOLE_SCREEN_BUFFER_INFOEX {
DWORD cbSize;
COORD dwSize;
COORD dwCursorPosition;
CONSOLE_CHARACTER_ATTRIBUTES wAttributes;
SMALL_RECT srWindow;
COORD dwMaximumWindowSize;
WORD wPopupAttributes;
BOOL bFullscreenSupported;
COLORREF ColorTable[16];
} CONSOLE_SCREEN_BUFFER_INFOEX;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct COORD
{
public short X;
public short Y;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SMALL_RECT
{
public short Left;
public short Top;
public short Right;
public short Bottom;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CONSOLE_SCREEN_BUFFER_INFOEX
{
public uint cbSize;
public COORD dwSize;
public COORD dwCursorPosition;
public ushort wAttributes;
public SMALL_RECT srWindow;
public COORD dwMaximumWindowSize;
public ushort wPopupAttributes;
[MarshalAs(UnmanagedType.Bool)] public bool bFullscreenSupported;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)] public uint[] ColorTable;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure COORD
Public X As Short
Public Y As Short
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SMALL_RECT
Public Left As Short
Public Top As Short
Public Right As Short
Public Bottom As Short
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CONSOLE_SCREEN_BUFFER_INFOEX
Public cbSize As UInteger
Public dwSize As COORD
Public dwCursorPosition As COORD
Public wAttributes As UShort
Public srWindow As SMALL_RECT
Public dwMaximumWindowSize As COORD
Public wPopupAttributes As UShort
<MarshalAs(UnmanagedType.Bool)> Public bFullscreenSupported As Boolean
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=16)> Public ColorTable() As UInteger
End Structureimport ctypes
from ctypes import wintypes
class COORD(ctypes.Structure):
_fields_ = [
("X", ctypes.c_short),
("Y", ctypes.c_short),
]
class SMALL_RECT(ctypes.Structure):
_fields_ = [
("Left", ctypes.c_short),
("Top", ctypes.c_short),
("Right", ctypes.c_short),
("Bottom", ctypes.c_short),
]
class CONSOLE_SCREEN_BUFFER_INFOEX(ctypes.Structure):
_fields_ = [
("cbSize", wintypes.DWORD),
("dwSize", COORD),
("dwCursorPosition", COORD),
("wAttributes", ctypes.c_ushort),
("srWindow", SMALL_RECT),
("dwMaximumWindowSize", COORD),
("wPopupAttributes", ctypes.c_ushort),
("bFullscreenSupported", wintypes.BOOL),
("ColorTable", wintypes.DWORD * 16),
]#[repr(C)]
pub struct COORD {
pub X: i16,
pub Y: i16,
}
#[repr(C)]
pub struct SMALL_RECT {
pub Left: i16,
pub Top: i16,
pub Right: i16,
pub Bottom: i16,
}
#[repr(C)]
pub struct CONSOLE_SCREEN_BUFFER_INFOEX {
pub cbSize: u32,
pub dwSize: COORD,
pub dwCursorPosition: COORD,
pub wAttributes: u16,
pub srWindow: SMALL_RECT,
pub dwMaximumWindowSize: COORD,
pub wPopupAttributes: u16,
pub bFullscreenSupported: i32,
pub ColorTable: [u32; 16],
}import "golang.org/x/sys/windows"
type COORD struct {
X int16
Y int16
}
type SMALL_RECT struct {
Left int16
Top int16
Right int16
Bottom int16
}
type CONSOLE_SCREEN_BUFFER_INFOEX struct {
cbSize uint32
dwSize COORD
dwCursorPosition COORD
wAttributes uint16
srWindow SMALL_RECT
dwMaximumWindowSize COORD
wPopupAttributes uint16
bFullscreenSupported int32
ColorTable [16]uint32
}type
COORD = record
X: Smallint;
Y: Smallint;
end;
SMALL_RECT = record
Left: Smallint;
Top: Smallint;
Right: Smallint;
Bottom: Smallint;
end;
CONSOLE_SCREEN_BUFFER_INFOEX = record
cbSize: DWORD;
dwSize: COORD;
dwCursorPosition: COORD;
wAttributes: Word;
srWindow: SMALL_RECT;
dwMaximumWindowSize: COORD;
wPopupAttributes: Word;
bFullscreenSupported: BOOL;
ColorTable: array[0..15] of DWORD;
end;const COORD = extern struct {
X: i16,
Y: i16,
};
const SMALL_RECT = extern struct {
Left: i16,
Top: i16,
Right: i16,
Bottom: i16,
};
const CONSOLE_SCREEN_BUFFER_INFOEX = extern struct {
cbSize: u32,
dwSize: COORD,
dwCursorPosition: COORD,
wAttributes: u16,
srWindow: SMALL_RECT,
dwMaximumWindowSize: COORD,
wPopupAttributes: u16,
bFullscreenSupported: i32,
ColorTable: [16]u32,
};type
COORD {.bycopy.} = object
X: int16
Y: int16
SMALL_RECT {.bycopy.} = object
Left: int16
Top: int16
Right: int16
Bottom: int16
CONSOLE_SCREEN_BUFFER_INFOEX {.bycopy.} = object
cbSize: uint32
dwSize: COORD
dwCursorPosition: COORD
wAttributes: uint16
srWindow: SMALL_RECT
dwMaximumWindowSize: COORD
wPopupAttributes: uint16
bFullscreenSupported: int32
ColorTable: array[16, uint32]struct COORD
{
short X;
short Y;
}
struct SMALL_RECT
{
short Left;
short Top;
short Right;
short Bottom;
}
struct CONSOLE_SCREEN_BUFFER_INFOEX
{
uint cbSize;
COORD dwSize;
COORD dwCursorPosition;
ushort wAttributes;
SMALL_RECT srWindow;
COORD dwMaximumWindowSize;
ushort wPopupAttributes;
int bFullscreenSupported;
uint[16] ColorTable;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; CONSOLE_SCREEN_BUFFER_INFOEX サイズ: 96 バイト(x64)
dim st, 24 ; 4byte整数×24(構造体サイズ 96 / 4 切り上げ)
; cbSize : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; dwSize : COORD (+4, 4byte) varptr(st)+4 を基点に操作(4byte:入れ子/配列)
; dwCursorPosition : COORD (+8, 4byte) varptr(st)+8 を基点に操作(4byte:入れ子/配列)
; wAttributes : CONSOLE_CHARACTER_ATTRIBUTES (+12, 2byte) wpoke st,12,値 / 値 = wpeek(st,12)
; srWindow : SMALL_RECT (+14, 8byte) varptr(st)+14 を基点に操作(8byte:入れ子/配列)
; dwMaximumWindowSize : COORD (+22, 4byte) varptr(st)+22 を基点に操作(4byte:入れ子/配列)
; wPopupAttributes : WORD (+26, 2byte) wpoke st,26,値 / 値 = wpeek(st,26)
; bFullscreenSupported : BOOL (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; ColorTable : COLORREF (+32, 64byte) varptr(st)+32 を基点に操作(64byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global COORD
#field short X
#field short Y
#endstruct
#defstruct global SMALL_RECT
#field short Left
#field short Top
#field short Right
#field short Bottom
#endstruct
#defstruct global CONSOLE_SCREEN_BUFFER_INFOEX
#field int cbSize
#field COORD dwSize
#field COORD dwCursorPosition
#field short wAttributes
#field SMALL_RECT srWindow
#field COORD dwMaximumWindowSize
#field short wPopupAttributes
#field bool bFullscreenSupported
#field int ColorTable 16
#endstruct
stdim st, CONSOLE_SCREEN_BUFFER_INFOEX ; NSTRUCT 変数を確保
st->cbSize = 100
mes "cbSize=" + st->cbSize