ホーム › Foundation › POINTS
POINTS
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| x | SHORT | 2 | +0 | +0 | 点のx座標(16ビット符号付き)。 |
| y | SHORT | 2 | +2 | +2 | 点のy座標(16ビット符号付き)。 |
各言語での定義
#include <windows.h>
// POINTS (x64 4 / x86 4 バイト)
typedef struct POINTS {
SHORT x;
SHORT y;
} POINTS;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct POINTS
{
public short x;
public short y;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure POINTS
Public x As Short
Public y As Short
End Structureimport ctypes
from ctypes import wintypes
class POINTS(ctypes.Structure):
_fields_ = [
("x", ctypes.c_short),
("y", ctypes.c_short),
]#[repr(C)]
pub struct POINTS {
pub x: i16,
pub y: i16,
}import "golang.org/x/sys/windows"
type POINTS struct {
x int16
y int16
}type
POINTS = record
x: Smallint;
y: Smallint;
end;const POINTS = extern struct {
x: i16,
y: i16,
};type
POINTS {.bycopy.} = object
x: int16
y: int16struct POINTS
{
short x;
short y;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; POINTS サイズ: 4 バイト(x64)
dim st, 1 ; 4byte整数×1(構造体サイズ 4 / 4 切り上げ)
; x : SHORT (+0, 2byte) wpoke st,0,値 / 値 = wpeek(st,0)
; y : SHORT (+2, 2byte) wpoke st,2,値 / 値 = wpeek(st,2)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global POINTS
#field short x
#field short y
#endstruct
stdim st, POINTS ; NSTRUCT 変数を確保
st->x = 100
mes "x=" + st->x