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

DIMOUSESTATE

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

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

フィールド

フィールドサイズx64x86説明
lXINT4+0+0X軸の相対移動量。
lYINT4+4+4Y軸の相対移動量。
lZINT4+8+8Z軸(ホイール)の相対移動量。
rgbButtonsBYTE4+12+12各マウスボタンの状態を示すバイト配列。最上位ビットで押下を表す。

各言語での定義

#include <windows.h>

// DIMOUSESTATE  (x64 16 / x86 16 バイト)
typedef struct DIMOUSESTATE {
    INT lX;
    INT lY;
    INT lZ;
    BYTE rgbButtons[4];
} DIMOUSESTATE;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DIMOUSESTATE
{
    public int lX;
    public int lY;
    public int lZ;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public byte[] rgbButtons;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DIMOUSESTATE
    Public lX As Integer
    Public lY As Integer
    Public lZ As Integer
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=4)> Public rgbButtons() As Byte
End Structure
import ctypes
from ctypes import wintypes

class DIMOUSESTATE(ctypes.Structure):
    _fields_ = [
        ("lX", ctypes.c_int),
        ("lY", ctypes.c_int),
        ("lZ", ctypes.c_int),
        ("rgbButtons", ctypes.c_ubyte * 4),
    ]
#[repr(C)]
pub struct DIMOUSESTATE {
    pub lX: i32,
    pub lY: i32,
    pub lZ: i32,
    pub rgbButtons: [u8; 4],
}
import "golang.org/x/sys/windows"

type DIMOUSESTATE struct {
	lX int32
	lY int32
	lZ int32
	rgbButtons [4]byte
}
type
  DIMOUSESTATE = record
    lX: Integer;
    lY: Integer;
    lZ: Integer;
    rgbButtons: array[0..3] of Byte;
  end;
const DIMOUSESTATE = extern struct {
    lX: i32,
    lY: i32,
    lZ: i32,
    rgbButtons: [4]u8,
};
type
  DIMOUSESTATE {.bycopy.} = object
    lX: int32
    lY: int32
    lZ: int32
    rgbButtons: array[4, uint8]
struct DIMOUSESTATE
{
    int lX;
    int lY;
    int lZ;
    ubyte[4] rgbButtons;
}

HSP用 定義

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

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

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