Win32 API 日本語リファレンス
ホームUI.Input.Pointer › POINTER_PEN_INFO

POINTER_PEN_INFO

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

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

フィールド

フィールドサイズx64x86説明
pointerInfoPOINTER_INFO96/88+0+0共通のポインタ情報(POINTER_INFO)。座標や状態の基本データを保持する。
penFlagsDWORD4+96+88ペン固有のフラグ。バレルボタン・反転・消しゴム等の状態を示す。
penMaskDWORD4+100+92pressure・rotation・tiltX・tiltYのうち有効な値を示すマスク。
pressureDWORD4+104+96ペンの筆圧(0〜1024)。サポートしない場合は0。
rotationDWORD4+108+100ペンの回転角(0〜359度)。
tiltXINT4+112+104X軸方向のペン傾斜角(-90〜90度)。
tiltYINT4+116+108Y軸方向のペン傾斜角(-90〜90度)。

各言語での定義

#include <windows.h>

// POINT  (x64 8 / x86 8 バイト)
typedef struct POINT {
    INT x;
    INT y;
} POINT;

// POINTER_INFO  (x64 96 / x86 88 バイト)
typedef struct POINTER_INFO {
    POINTER_INPUT_TYPE pointerType;
    DWORD pointerId;
    DWORD frameId;
    POINTER_FLAGS pointerFlags;
    HANDLE sourceDevice;
    HWND hwndTarget;
    POINT ptPixelLocation;
    POINT ptHimetricLocation;
    POINT ptPixelLocationRaw;
    POINT ptHimetricLocationRaw;
    DWORD dwTime;
    DWORD historyCount;
    INT InputData;
    DWORD dwKeyStates;
    ULONGLONG PerformanceCount;
    POINTER_BUTTON_CHANGE_TYPE ButtonChangeType;
} POINTER_INFO;

// POINTER_PEN_INFO  (x64 120 / x86 112 バイト)
typedef struct POINTER_PEN_INFO {
    POINTER_INFO pointerInfo;
    DWORD penFlags;
    DWORD penMask;
    DWORD pressure;
    DWORD rotation;
    INT tiltX;
    INT tiltY;
} POINTER_PEN_INFO;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct POINT
{
    public int x;
    public int y;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct POINTER_INFO
{
    public int pointerType;
    public uint pointerId;
    public uint frameId;
    public uint pointerFlags;
    public IntPtr sourceDevice;
    public IntPtr hwndTarget;
    public POINT ptPixelLocation;
    public POINT ptHimetricLocation;
    public POINT ptPixelLocationRaw;
    public POINT ptHimetricLocationRaw;
    public uint dwTime;
    public uint historyCount;
    public int InputData;
    public uint dwKeyStates;
    public ulong PerformanceCount;
    public int ButtonChangeType;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct POINTER_PEN_INFO
{
    public POINTER_INFO pointerInfo;
    public uint penFlags;
    public uint penMask;
    public uint pressure;
    public uint rotation;
    public int tiltX;
    public int tiltY;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure POINT
    Public x As Integer
    Public y As Integer
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure POINTER_INFO
    Public pointerType As Integer
    Public pointerId As UInteger
    Public frameId As UInteger
    Public pointerFlags As UInteger
    Public sourceDevice As IntPtr
    Public hwndTarget As IntPtr
    Public ptPixelLocation As POINT
    Public ptHimetricLocation As POINT
    Public ptPixelLocationRaw As POINT
    Public ptHimetricLocationRaw As POINT
    Public dwTime As UInteger
    Public historyCount As UInteger
    Public InputData As Integer
    Public dwKeyStates As UInteger
    Public PerformanceCount As ULong
    Public ButtonChangeType As Integer
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure POINTER_PEN_INFO
    Public pointerInfo As POINTER_INFO
    Public penFlags As UInteger
    Public penMask As UInteger
    Public pressure As UInteger
    Public rotation As UInteger
    Public tiltX As Integer
    Public tiltY As Integer
End Structure
import ctypes
from ctypes import wintypes

class POINT(ctypes.Structure):
    _fields_ = [
        ("x", ctypes.c_int),
        ("y", ctypes.c_int),
    ]

class POINTER_INFO(ctypes.Structure):
    _fields_ = [
        ("pointerType", ctypes.c_int),
        ("pointerId", wintypes.DWORD),
        ("frameId", wintypes.DWORD),
        ("pointerFlags", wintypes.DWORD),
        ("sourceDevice", ctypes.c_void_p),
        ("hwndTarget", ctypes.c_void_p),
        ("ptPixelLocation", POINT),
        ("ptHimetricLocation", POINT),
        ("ptPixelLocationRaw", POINT),
        ("ptHimetricLocationRaw", POINT),
        ("dwTime", wintypes.DWORD),
        ("historyCount", wintypes.DWORD),
        ("InputData", ctypes.c_int),
        ("dwKeyStates", wintypes.DWORD),
        ("PerformanceCount", ctypes.c_ulonglong),
        ("ButtonChangeType", ctypes.c_int),
    ]

class POINTER_PEN_INFO(ctypes.Structure):
    _fields_ = [
        ("pointerInfo", POINTER_INFO),
        ("penFlags", wintypes.DWORD),
        ("penMask", wintypes.DWORD),
        ("pressure", wintypes.DWORD),
        ("rotation", wintypes.DWORD),
        ("tiltX", ctypes.c_int),
        ("tiltY", ctypes.c_int),
    ]
#[repr(C)]
pub struct POINT {
    pub x: i32,
    pub y: i32,
}

#[repr(C)]
pub struct POINTER_INFO {
    pub pointerType: i32,
    pub pointerId: u32,
    pub frameId: u32,
    pub pointerFlags: u32,
    pub sourceDevice: *mut core::ffi::c_void,
    pub hwndTarget: *mut core::ffi::c_void,
    pub ptPixelLocation: POINT,
    pub ptHimetricLocation: POINT,
    pub ptPixelLocationRaw: POINT,
    pub ptHimetricLocationRaw: POINT,
    pub dwTime: u32,
    pub historyCount: u32,
    pub InputData: i32,
    pub dwKeyStates: u32,
    pub PerformanceCount: u64,
    pub ButtonChangeType: i32,
}

#[repr(C)]
pub struct POINTER_PEN_INFO {
    pub pointerInfo: POINTER_INFO,
    pub penFlags: u32,
    pub penMask: u32,
    pub pressure: u32,
    pub rotation: u32,
    pub tiltX: i32,
    pub tiltY: i32,
}
import "golang.org/x/sys/windows"

type POINT struct {
	x int32
	y int32
}

type POINTER_INFO struct {
	pointerType int32
	pointerId uint32
	frameId uint32
	pointerFlags uint32
	sourceDevice uintptr
	hwndTarget uintptr
	ptPixelLocation POINT
	ptHimetricLocation POINT
	ptPixelLocationRaw POINT
	ptHimetricLocationRaw POINT
	dwTime uint32
	historyCount uint32
	InputData int32
	dwKeyStates uint32
	PerformanceCount uint64
	ButtonChangeType int32
}

type POINTER_PEN_INFO struct {
	pointerInfo POINTER_INFO
	penFlags uint32
	penMask uint32
	pressure uint32
	rotation uint32
	tiltX int32
	tiltY int32
}
type
  POINT = record
    x: Integer;
    y: Integer;
  end;

  POINTER_INFO = record
    pointerType: Integer;
    pointerId: DWORD;
    frameId: DWORD;
    pointerFlags: DWORD;
    sourceDevice: Pointer;
    hwndTarget: Pointer;
    ptPixelLocation: POINT;
    ptHimetricLocation: POINT;
    ptPixelLocationRaw: POINT;
    ptHimetricLocationRaw: POINT;
    dwTime: DWORD;
    historyCount: DWORD;
    InputData: Integer;
    dwKeyStates: DWORD;
    PerformanceCount: UInt64;
    ButtonChangeType: Integer;
  end;

  POINTER_PEN_INFO = record
    pointerInfo: POINTER_INFO;
    penFlags: DWORD;
    penMask: DWORD;
    pressure: DWORD;
    rotation: DWORD;
    tiltX: Integer;
    tiltY: Integer;
  end;
const POINT = extern struct {
    x: i32,
    y: i32,
};

const POINTER_INFO = extern struct {
    pointerType: i32,
    pointerId: u32,
    frameId: u32,
    pointerFlags: u32,
    sourceDevice: ?*anyopaque,
    hwndTarget: ?*anyopaque,
    ptPixelLocation: POINT,
    ptHimetricLocation: POINT,
    ptPixelLocationRaw: POINT,
    ptHimetricLocationRaw: POINT,
    dwTime: u32,
    historyCount: u32,
    InputData: i32,
    dwKeyStates: u32,
    PerformanceCount: u64,
    ButtonChangeType: i32,
};

const POINTER_PEN_INFO = extern struct {
    pointerInfo: POINTER_INFO,
    penFlags: u32,
    penMask: u32,
    pressure: u32,
    rotation: u32,
    tiltX: i32,
    tiltY: i32,
};
type
  POINT {.bycopy.} = object
    x: int32
    y: int32

  POINTER_INFO {.bycopy.} = object
    pointerType: int32
    pointerId: uint32
    frameId: uint32
    pointerFlags: uint32
    sourceDevice: pointer
    hwndTarget: pointer
    ptPixelLocation: POINT
    ptHimetricLocation: POINT
    ptPixelLocationRaw: POINT
    ptHimetricLocationRaw: POINT
    dwTime: uint32
    historyCount: uint32
    InputData: int32
    dwKeyStates: uint32
    PerformanceCount: uint64
    ButtonChangeType: int32

  POINTER_PEN_INFO {.bycopy.} = object
    pointerInfo: POINTER_INFO
    penFlags: uint32
    penMask: uint32
    pressure: uint32
    rotation: uint32
    tiltX: int32
    tiltY: int32
struct POINT
{
    int x;
    int y;
}

struct POINTER_INFO
{
    int pointerType;
    uint pointerId;
    uint frameId;
    uint pointerFlags;
    void* sourceDevice;
    void* hwndTarget;
    POINT ptPixelLocation;
    POINT ptHimetricLocation;
    POINT ptPixelLocationRaw;
    POINT ptHimetricLocationRaw;
    uint dwTime;
    uint historyCount;
    int InputData;
    uint dwKeyStates;
    ulong PerformanceCount;
    int ButtonChangeType;
}

struct POINTER_PEN_INFO
{
    POINTER_INFO pointerInfo;
    uint penFlags;
    uint penMask;
    uint pressure;
    uint rotation;
    int tiltX;
    int tiltY;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; POINTER_PEN_INFO サイズ: 112 バイト(x86)
dim st, 28    ; 4byte整数×28(構造体サイズ 112 / 4 切り上げ)
; pointerInfo : POINTER_INFO (+0, 88byte)  varptr(st)+0 を基点に操作(88byte:入れ子/配列)
; penFlags : DWORD (+88, 4byte)  st.22 = 値  /  値 = st.22   (lpoke/lpeek も可)
; penMask : DWORD (+92, 4byte)  st.23 = 値  /  値 = st.23   (lpoke/lpeek も可)
; pressure : DWORD (+96, 4byte)  st.24 = 値  /  値 = st.24   (lpoke/lpeek も可)
; rotation : DWORD (+100, 4byte)  st.25 = 値  /  値 = st.25   (lpoke/lpeek も可)
; tiltX : INT (+104, 4byte)  st.26 = 値  /  値 = st.26   (lpoke/lpeek も可)
; tiltY : INT (+108, 4byte)  st.27 = 値  /  値 = st.27   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; POINTER_PEN_INFO サイズ: 120 バイト(x64)
dim st, 30    ; 4byte整数×30(構造体サイズ 120 / 4 切り上げ)
; pointerInfo : POINTER_INFO (+0, 96byte)  varptr(st)+0 を基点に操作(96byte:入れ子/配列)
; penFlags : DWORD (+96, 4byte)  st.24 = 値  /  値 = st.24   (lpoke/lpeek も可)
; penMask : DWORD (+100, 4byte)  st.25 = 値  /  値 = st.25   (lpoke/lpeek も可)
; pressure : DWORD (+104, 4byte)  st.26 = 値  /  値 = st.26   (lpoke/lpeek も可)
; rotation : DWORD (+108, 4byte)  st.27 = 値  /  値 = st.27   (lpoke/lpeek も可)
; tiltX : INT (+112, 4byte)  st.28 = 値  /  値 = st.28   (lpoke/lpeek も可)
; tiltY : INT (+116, 4byte)  st.29 = 値  /  値 = st.29   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global POINT
    #field int x
    #field int y
#endstruct

#defstruct global POINTER_INFO
    #field int pointerType
    #field int pointerId
    #field int frameId
    #field int pointerFlags
    #field intptr sourceDevice
    #field intptr hwndTarget
    #field POINT ptPixelLocation
    #field POINT ptHimetricLocation
    #field POINT ptPixelLocationRaw
    #field POINT ptHimetricLocationRaw
    #field int dwTime
    #field int historyCount
    #field int InputData
    #field int dwKeyStates
    #field int64 PerformanceCount
    #field int ButtonChangeType
#endstruct

#defstruct global POINTER_PEN_INFO
    #field POINTER_INFO pointerInfo
    #field int penFlags
    #field int penMask
    #field int pressure
    #field int rotation
    #field int tiltX
    #field int tiltY
#endstruct

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