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

GetPointerDeviceRects

関数
ポインターデバイスの入力範囲と表示先矩形を取得する。
DLLUSER32.dll呼出規約winapiSetLastErrorあり対応OSwindows8.0

シグネチャ

// USER32.dll
#include <windows.h>

BOOL GetPointerDeviceRects(
    HANDLE device,
    RECT* pointerDeviceRect,
    RECT* displayRect
);

パラメーター

名前方向説明
deviceHANDLEin対象ポインタデバイスのハンドルを指定する。
pointerDeviceRectRECT*outデバイス固有座標系の矩形を受け取るRECTへのポインタ。
displayRectRECT*out対応する画面表示領域の矩形を受け取るRECTへのポインタ。

戻り値の型: BOOL

各言語での呼び出し定義

// USER32.dll
#include <windows.h>

BOOL GetPointerDeviceRects(
    HANDLE device,
    RECT* pointerDeviceRect,
    RECT* displayRect
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool GetPointerDeviceRects(
    IntPtr device,   // HANDLE
    IntPtr pointerDeviceRect,   // RECT* out
    IntPtr displayRect   // RECT* out
);
<DllImport("USER32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetPointerDeviceRects(
    device As IntPtr,   ' HANDLE
    pointerDeviceRect As IntPtr,   ' RECT* out
    displayRect As IntPtr   ' RECT* out
) As Boolean
End Function
' device : HANDLE
' pointerDeviceRect : RECT* out
' displayRect : RECT* out
Declare PtrSafe Function GetPointerDeviceRects Lib "user32" ( _
    ByVal device As LongPtr, _
    ByVal pointerDeviceRect As LongPtr, _
    ByVal displayRect As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetPointerDeviceRects = ctypes.windll.user32.GetPointerDeviceRects
GetPointerDeviceRects.restype = wintypes.BOOL
GetPointerDeviceRects.argtypes = [
    wintypes.HANDLE,  # device : HANDLE
    ctypes.c_void_p,  # pointerDeviceRect : RECT* out
    ctypes.c_void_p,  # displayRect : RECT* out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('USER32.dll')
GetPointerDeviceRects = Fiddle::Function.new(
  lib['GetPointerDeviceRects'],
  [
    Fiddle::TYPE_VOIDP,  # device : HANDLE
    Fiddle::TYPE_VOIDP,  # pointerDeviceRect : RECT* out
    Fiddle::TYPE_VOIDP,  # displayRect : RECT* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "user32")]
extern "system" {
    fn GetPointerDeviceRects(
        device: *mut core::ffi::c_void,  // HANDLE
        pointerDeviceRect: *mut RECT,  // RECT* out
        displayRect: *mut RECT  // RECT* out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", SetLastError = true)]
public static extern bool GetPointerDeviceRects(IntPtr device, IntPtr pointerDeviceRect, IntPtr displayRect);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_GetPointerDeviceRects' -Namespace Win32 -PassThru
# $api::GetPointerDeviceRects(device, pointerDeviceRect, displayRect)
#uselib "USER32.dll"
#func global GetPointerDeviceRects "GetPointerDeviceRects" sptr, sptr, sptr
; GetPointerDeviceRects device, varptr(pointerDeviceRect), varptr(displayRect)   ; 戻り値は stat
; device : HANDLE -> "sptr"
; pointerDeviceRect : RECT* out -> "sptr"
; displayRect : RECT* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "USER32.dll"
#cfunc global GetPointerDeviceRects "GetPointerDeviceRects" sptr, var, var
; res = GetPointerDeviceRects(device, pointerDeviceRect, displayRect)
; device : HANDLE -> "sptr"
; pointerDeviceRect : RECT* out -> "var"
; displayRect : RECT* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL GetPointerDeviceRects(HANDLE device, RECT* pointerDeviceRect, RECT* displayRect)
#uselib "USER32.dll"
#cfunc global GetPointerDeviceRects "GetPointerDeviceRects" intptr, var, var
; res = GetPointerDeviceRects(device, pointerDeviceRect, displayRect)
; device : HANDLE -> "intptr"
; pointerDeviceRect : RECT* out -> "var"
; displayRect : RECT* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procGetPointerDeviceRects = user32.NewProc("GetPointerDeviceRects")
)

// device (HANDLE), pointerDeviceRect (RECT* out), displayRect (RECT* out)
r1, _, err := procGetPointerDeviceRects.Call(
	uintptr(device),
	uintptr(pointerDeviceRect),
	uintptr(displayRect),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function GetPointerDeviceRects(
  device: THandle;   // HANDLE
  pointerDeviceRect: Pointer;   // RECT* out
  displayRect: Pointer   // RECT* out
): BOOL; stdcall;
  external 'USER32.dll' name 'GetPointerDeviceRects';
result := DllCall("USER32\GetPointerDeviceRects"
    , "Ptr", device   ; HANDLE
    , "Ptr", pointerDeviceRect   ; RECT* out
    , "Ptr", displayRect   ; RECT* out
    , "Int")   ; return: BOOL
●GetPointerDeviceRects(device, pointerDeviceRect, displayRect) = DLL("USER32.dll", "bool GetPointerDeviceRects(void*, void*, void*)")
# 呼び出し: GetPointerDeviceRects(device, pointerDeviceRect, displayRect)
# device : HANDLE -> "void*"
# pointerDeviceRect : RECT* out -> "void*"
# displayRect : RECT* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。