Win32 API 日本語リファレンス
ホームSystem.Console › SMALL_RECT

SMALL_RECT

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

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

フィールド

フィールドサイズx64x86説明
LeftSHORT2+0+0矩形の左端の列座標(SHORT)。
TopSHORT2+2+2矩形の上端の行座標(SHORT)。
RightSHORT2+4+4矩形の右端の列座標(SHORT)。
BottomSHORT2+6+6矩形の下端の行座標(SHORT)。

各言語での定義

#include <windows.h>

// SMALL_RECT  (x64 8 / x86 8 バイト)
typedef struct SMALL_RECT {
    SHORT Left;
    SHORT Top;
    SHORT Right;
    SHORT Bottom;
} SMALL_RECT;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SMALL_RECT
{
    public short Left;
    public short Top;
    public short Right;
    public short Bottom;
}
Imports System.Runtime.InteropServices

<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
import ctypes
from ctypes import wintypes

class SMALL_RECT(ctypes.Structure):
    _fields_ = [
        ("Left", ctypes.c_short),
        ("Top", ctypes.c_short),
        ("Right", ctypes.c_short),
        ("Bottom", ctypes.c_short),
    ]
#[repr(C)]
pub struct SMALL_RECT {
    pub Left: i16,
    pub Top: i16,
    pub Right: i16,
    pub Bottom: i16,
}
import "golang.org/x/sys/windows"

type SMALL_RECT struct {
	Left int16
	Top int16
	Right int16
	Bottom int16
}
type
  SMALL_RECT = record
    Left: Smallint;
    Top: Smallint;
    Right: Smallint;
    Bottom: Smallint;
  end;
const SMALL_RECT = extern struct {
    Left: i16,
    Top: i16,
    Right: i16,
    Bottom: i16,
};
type
  SMALL_RECT {.bycopy.} = object
    Left: int16
    Top: int16
    Right: int16
    Bottom: int16
struct SMALL_RECT
{
    short Left;
    short Top;
    short Right;
    short Bottom;
}

HSP用 定義

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

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

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