GetPointerFramePenInfoHistory
関数シグネチャ
// USER32.dll
#include <windows.h>
BOOL GetPointerFramePenInfoHistory(
DWORD pointerId,
DWORD* entriesCount,
DWORD* pointerCount,
POINTER_PEN_INFO* penInfo // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pointerId | DWORD | in | フレーム情報を取得する対象のポインターの識別子。 |
| entriesCount | DWORD* | inout | penInfo が指す 2 次元配列の行数を指定する変数へのポインター。GetPointerFramePenInfoHistory が成功した場合、entriesCount は履歴内で利用可能なフレームの総数に更新されます。 |
| pointerCount | DWORD* | inout | penInfo が指す 2 次元配列の列数を指定する変数へのポインター。GetPointerFramePenInfoHistory が成功した場合、pointerCount は各フレーム内のポインターの総数に更新されます。 |
| penInfo | POINTER_PEN_INFO* | outoptional | ポインター情報を受け取る POINTER_PEN_INFO 構造体の 2 次元配列のアドレス。*entriesCount と *pointerCount がどちらも 0 の場合、このパラメーターは NULL にできます。 この配列は POINTER_PEN_INFO[*entriesCount][*pointerCount] として解釈されます。 |
戻り値の型: BOOL
公式ドキュメント
現在のメッセージに関連付けられた、指定されたポインター (PT_PEN 型) に関するペンベースの情報のフレーム全体 (結合された入力フレームを含む) を取得します。
戻り値
関数が成功した場合、戻り値は 0 以外です。
関数が失敗した場合、戻り値は 0 です。拡張エラー情報を取得するには、GetLastError を呼び出します。
解説(Remarks)
パラレルモードのデバイスは、ポインター入力をフレーム単位で報告することがあります。つまり、そのデバイス上のすべてのポインターの状態と位置を、1 回の入力レポートとしてシステムに報告する場合があります。アプリケーション固有の要件で別の扱いが必要でない限り、アプリケーションはフレーム全体を 1 つの入力として扱うことが理想的です。
GetPointerFramePenInfo が返す情報は、呼び出し元スレッドが取得した最新のポインター (PT_PEN) メッセージに関連付けられています。呼び出し元スレッドが次のメッセージを取得すると、前のメッセージに関連付けられた情報は利用できなくなる場合があります。
アプリケーションがポインター入力メッセージを生成される速度で処理できない場合、一部のメッセージは WM_POINTERUPDATE メッセージに結合されることがあります。最新の WM_POINTERUPDATE メッセージからメッセージ履歴 (結合された入力フレームを含む) を取得するには、GetPointerFramePenInfoHistory を使用します。
フレーム全体の情報を取得した後、アプリケーションは SkipPointerFrameMessages 関数を呼び出して、このフレームに関連付けられた、取得待ちの残りのポインターメッセージをスキップできます。これにより、残りのメッセージを 1 つずつ取得して処理するオーバーヘッドを省けます。ただし、SkipPointerFrameMessages 関数は注意して使用する必要があり、呼び出し元のスレッド上の他のエンティティが残りのポインターメッセージを取得順に 1 つずつ受け取ることを想定していないと確信できる場合にのみ使用してください。
フレームには、指定されたポインターと同じウィンドウが現在所有しているポインターのみが含まれます。
取得される情報は、履歴エントリごとに 1 行、フレーム内のポインターごとに 1 列を持つ 2 次元配列を表します。
取得される情報は新しいものから順 (逆時系列) に並び、最新のエントリは返される配列の先頭行に格納されます。最新のエントリは、GetPointerFramePenInfo 関数が返すものと同じです。
指定されたバッファーの行数が、利用可能なすべての履歴エントリを保持するのに不十分な場合、この関数は成功し、バッファーには最新のエントリが格納され、*entriesCount には利用可能なエントリの総数が格納されます。
ポインターフレームに、指定されたポインター以外のポインターが含まれていない場合、この関数は成功し、指定されたポインターの情報のみを返します。
ポインターフレームに関連付けられた情報が既に利用できない場合、この関数は失敗し、最終エラーは ERROR_NO_DATA に設定されます。
ポインターメッセージが配信されたウィンドウ (入力が最初に配信されたウィンドウ、またはメッセージが転送されたウィンドウ) を呼び出し元スレッドが所有していない場合、この関数は失敗し、最終エラーは ERROR_ACCESS_DENIED に設定されます。
指定されたポインターが PT_PEN 型でない場合、この関数は失敗し、最終エラーは ERROR_DATATYPE_MISMATCH に設定されます。
クライアント領域と非クライアント領域の両方を持つアプリの場合、入力フレームにはクライアントデータと非クライアントデータの両方が含まれることがあります。クライアントデータと非クライアントデータを区別するには、対象のウィンドウでヒットテストを実行する必要があります。
入力フレームからデータをフィルター処理する場合は、次の方法をお勧めします。
- ポインターの接触を含まない更新 (POINTER_FLAG_INCONTACT を伴わない POINTER_FLAG_UPDATE) ごとに、ヒットテストを行って入力がクライアントか非クライアントかを判断します。
- 新しい接触 (POINTER_FLAG_DOWN) ごとに、ヒットテストを行って入力がクライアントか非クライアントかを判断し、その情報を追跡します。
- ポインターの接触を含む更新 (POINTER_FLAG_INCONTACT を伴う POINTER_FLAG_UPDATE) ごとに、追跡情報を使用して入力がクライアントか非クライアントかを判断します。
- POINTER_FLAG_UP ごとに、追跡情報を使用して入力がクライアントか非クライアントかを判断し、その後このポインターを追跡データから削除します。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// USER32.dll
#include <windows.h>
BOOL GetPointerFramePenInfoHistory(
DWORD pointerId,
DWORD* entriesCount,
DWORD* pointerCount,
POINTER_PEN_INFO* penInfo // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool GetPointerFramePenInfoHistory(
uint pointerId, // DWORD
ref uint entriesCount, // DWORD* in/out
ref uint pointerCount, // DWORD* in/out
IntPtr penInfo // POINTER_PEN_INFO* optional, out
);<DllImport("USER32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetPointerFramePenInfoHistory(
pointerId As UInteger, ' DWORD
ByRef entriesCount As UInteger, ' DWORD* in/out
ByRef pointerCount As UInteger, ' DWORD* in/out
penInfo As IntPtr ' POINTER_PEN_INFO* optional, out
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' pointerId : DWORD
' entriesCount : DWORD* in/out
' pointerCount : DWORD* in/out
' penInfo : POINTER_PEN_INFO* optional, out
Declare PtrSafe Function GetPointerFramePenInfoHistory Lib "user32" ( _
ByVal pointerId As Long, _
ByRef entriesCount As Long, _
ByRef pointerCount As Long, _
ByVal penInfo As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetPointerFramePenInfoHistory = ctypes.windll.user32.GetPointerFramePenInfoHistory
GetPointerFramePenInfoHistory.restype = wintypes.BOOL
GetPointerFramePenInfoHistory.argtypes = [
wintypes.DWORD, # pointerId : DWORD
ctypes.POINTER(wintypes.DWORD), # entriesCount : DWORD* in/out
ctypes.POINTER(wintypes.DWORD), # pointerCount : DWORD* in/out
ctypes.c_void_p, # penInfo : POINTER_PEN_INFO* optional, out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USER32.dll')
GetPointerFramePenInfoHistory = Fiddle::Function.new(
lib['GetPointerFramePenInfoHistory'],
[
-Fiddle::TYPE_INT, # pointerId : DWORD
Fiddle::TYPE_VOIDP, # entriesCount : DWORD* in/out
Fiddle::TYPE_VOIDP, # pointerCount : DWORD* in/out
Fiddle::TYPE_VOIDP, # penInfo : POINTER_PEN_INFO* optional, out
],
Fiddle::TYPE_INT)#[link(name = "user32")]
extern "system" {
fn GetPointerFramePenInfoHistory(
pointerId: u32, // DWORD
entriesCount: *mut u32, // DWORD* in/out
pointerCount: *mut u32, // DWORD* in/out
penInfo: *mut POINTER_PEN_INFO // POINTER_PEN_INFO* optional, 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 GetPointerFramePenInfoHistory(uint pointerId, ref uint entriesCount, ref uint pointerCount, IntPtr penInfo);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_GetPointerFramePenInfoHistory' -Namespace Win32 -PassThru
# $api::GetPointerFramePenInfoHistory(pointerId, entriesCount, pointerCount, penInfo)#uselib "USER32.dll"
#func global GetPointerFramePenInfoHistory "GetPointerFramePenInfoHistory" sptr, sptr, sptr, sptr
; GetPointerFramePenInfoHistory pointerId, varptr(entriesCount), varptr(pointerCount), varptr(penInfo) ; 戻り値は stat
; pointerId : DWORD -> "sptr"
; entriesCount : DWORD* in/out -> "sptr"
; pointerCount : DWORD* in/out -> "sptr"
; penInfo : POINTER_PEN_INFO* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "USER32.dll" #cfunc global GetPointerFramePenInfoHistory "GetPointerFramePenInfoHistory" int, var, var, var ; res = GetPointerFramePenInfoHistory(pointerId, entriesCount, pointerCount, penInfo) ; pointerId : DWORD -> "int" ; entriesCount : DWORD* in/out -> "var" ; pointerCount : DWORD* in/out -> "var" ; penInfo : POINTER_PEN_INFO* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "USER32.dll" #cfunc global GetPointerFramePenInfoHistory "GetPointerFramePenInfoHistory" int, sptr, sptr, sptr ; res = GetPointerFramePenInfoHistory(pointerId, varptr(entriesCount), varptr(pointerCount), varptr(penInfo)) ; pointerId : DWORD -> "int" ; entriesCount : DWORD* in/out -> "sptr" ; pointerCount : DWORD* in/out -> "sptr" ; penInfo : POINTER_PEN_INFO* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
; BOOL GetPointerFramePenInfoHistory(DWORD pointerId, DWORD* entriesCount, DWORD* pointerCount, POINTER_PEN_INFO* penInfo) #uselib "USER32.dll" #cfunc global GetPointerFramePenInfoHistory "GetPointerFramePenInfoHistory" int, var, var, var ; res = GetPointerFramePenInfoHistory(pointerId, entriesCount, pointerCount, penInfo) ; pointerId : DWORD -> "int" ; entriesCount : DWORD* in/out -> "var" ; pointerCount : DWORD* in/out -> "var" ; penInfo : POINTER_PEN_INFO* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL GetPointerFramePenInfoHistory(DWORD pointerId, DWORD* entriesCount, DWORD* pointerCount, POINTER_PEN_INFO* penInfo) #uselib "USER32.dll" #cfunc global GetPointerFramePenInfoHistory "GetPointerFramePenInfoHistory" int, intptr, intptr, intptr ; res = GetPointerFramePenInfoHistory(pointerId, varptr(entriesCount), varptr(pointerCount), varptr(penInfo)) ; pointerId : DWORD -> "int" ; entriesCount : DWORD* in/out -> "intptr" ; pointerCount : DWORD* in/out -> "intptr" ; penInfo : POINTER_PEN_INFO* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
user32 = windows.NewLazySystemDLL("USER32.dll")
procGetPointerFramePenInfoHistory = user32.NewProc("GetPointerFramePenInfoHistory")
)
// pointerId (DWORD), entriesCount (DWORD* in/out), pointerCount (DWORD* in/out), penInfo (POINTER_PEN_INFO* optional, out)
r1, _, err := procGetPointerFramePenInfoHistory.Call(
uintptr(pointerId),
uintptr(entriesCount),
uintptr(pointerCount),
uintptr(penInfo),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction GetPointerFramePenInfoHistory(
pointerId: DWORD; // DWORD
entriesCount: Pointer; // DWORD* in/out
pointerCount: Pointer; // DWORD* in/out
penInfo: Pointer // POINTER_PEN_INFO* optional, out
): BOOL; stdcall;
external 'USER32.dll' name 'GetPointerFramePenInfoHistory';result := DllCall("USER32\GetPointerFramePenInfoHistory"
, "UInt", pointerId ; DWORD
, "Ptr", entriesCount ; DWORD* in/out
, "Ptr", pointerCount ; DWORD* in/out
, "Ptr", penInfo ; POINTER_PEN_INFO* optional, out
, "Int") ; return: BOOL●GetPointerFramePenInfoHistory(pointerId, entriesCount, pointerCount, penInfo) = DLL("USER32.dll", "bool GetPointerFramePenInfoHistory(dword, void*, void*, void*)")
# 呼び出し: GetPointerFramePenInfoHistory(pointerId, entriesCount, pointerCount, penInfo)
# pointerId : DWORD -> "dword"
# entriesCount : DWORD* in/out -> "void*"
# pointerCount : DWORD* in/out -> "void*"
# penInfo : POINTER_PEN_INFO* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "user32" fn GetPointerFramePenInfoHistory(
pointerId: u32, // DWORD
entriesCount: [*c]u32, // DWORD* in/out
pointerCount: [*c]u32, // DWORD* in/out
penInfo: [*c]POINTER_PEN_INFO // POINTER_PEN_INFO* optional, out
) callconv(std.os.windows.WINAPI) i32;proc GetPointerFramePenInfoHistory(
pointerId: uint32, # DWORD
entriesCount: ptr uint32, # DWORD* in/out
pointerCount: ptr uint32, # DWORD* in/out
penInfo: ptr POINTER_PEN_INFO # POINTER_PEN_INFO* optional, out
): int32 {.importc: "GetPointerFramePenInfoHistory", stdcall, dynlib: "USER32.dll".}pragma(lib, "user32");
extern(Windows)
int GetPointerFramePenInfoHistory(
uint pointerId, // DWORD
uint* entriesCount, // DWORD* in/out
uint* pointerCount, // DWORD* in/out
POINTER_PEN_INFO* penInfo // POINTER_PEN_INFO* optional, out
);ccall((:GetPointerFramePenInfoHistory, "USER32.dll"), stdcall, Int32,
(UInt32, Ptr{UInt32}, Ptr{UInt32}, Ptr{POINTER_PEN_INFO}),
pointerId, entriesCount, pointerCount, penInfo)
# pointerId : DWORD -> UInt32
# entriesCount : DWORD* in/out -> Ptr{UInt32}
# pointerCount : DWORD* in/out -> Ptr{UInt32}
# penInfo : POINTER_PEN_INFO* optional, out -> Ptr{POINTER_PEN_INFO}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t GetPointerFramePenInfoHistory(
uint32_t pointerId,
uint32_t* entriesCount,
uint32_t* pointerCount,
void* penInfo);
]]
local user32 = ffi.load("user32")
-- user32.GetPointerFramePenInfoHistory(pointerId, entriesCount, pointerCount, penInfo)
-- pointerId : DWORD
-- entriesCount : DWORD* in/out
-- pointerCount : DWORD* in/out
-- penInfo : POINTER_PEN_INFO* optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('USER32.dll');
const GetPointerFramePenInfoHistory = lib.func('__stdcall', 'GetPointerFramePenInfoHistory', 'int32_t', ['uint32_t', 'uint32_t *', 'uint32_t *', 'void *']);
// GetPointerFramePenInfoHistory(pointerId, entriesCount, pointerCount, penInfo)
// pointerId : DWORD -> 'uint32_t'
// entriesCount : DWORD* in/out -> 'uint32_t *'
// pointerCount : DWORD* in/out -> 'uint32_t *'
// penInfo : POINTER_PEN_INFO* optional, out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("USER32.dll", {
GetPointerFramePenInfoHistory: { parameters: ["u32", "pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.GetPointerFramePenInfoHistory(pointerId, entriesCount, pointerCount, penInfo)
// pointerId : DWORD -> "u32"
// entriesCount : DWORD* in/out -> "pointer"
// pointerCount : DWORD* in/out -> "pointer"
// penInfo : POINTER_PEN_INFO* optional, out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t GetPointerFramePenInfoHistory(
uint32_t pointerId,
uint32_t* entriesCount,
uint32_t* pointerCount,
void* penInfo);
C, "USER32.dll");
// $ffi->GetPointerFramePenInfoHistory(pointerId, entriesCount, pointerCount, penInfo);
// pointerId : DWORD
// entriesCount : DWORD* in/out
// pointerCount : DWORD* in/out
// penInfo : POINTER_PEN_INFO* optional, out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface User32 extends StdCallLibrary {
User32 INSTANCE = Native.load("user32", User32.class);
boolean GetPointerFramePenInfoHistory(
int pointerId, // DWORD
IntByReference entriesCount, // DWORD* in/out
IntByReference pointerCount, // DWORD* in/out
Pointer penInfo // POINTER_PEN_INFO* optional, out
);
}@[Link("user32")]
lib LibUSER32
fun GetPointerFramePenInfoHistory = GetPointerFramePenInfoHistory(
pointerId : UInt32, # DWORD
entriesCount : UInt32*, # DWORD* in/out
pointerCount : UInt32*, # DWORD* in/out
penInfo : POINTER_PEN_INFO* # POINTER_PEN_INFO* optional, out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef GetPointerFramePenInfoHistoryNative = Int32 Function(Uint32, Pointer<Uint32>, Pointer<Uint32>, Pointer<Void>);
typedef GetPointerFramePenInfoHistoryDart = int Function(int, Pointer<Uint32>, Pointer<Uint32>, Pointer<Void>);
final GetPointerFramePenInfoHistory = DynamicLibrary.open('USER32.dll')
.lookupFunction<GetPointerFramePenInfoHistoryNative, GetPointerFramePenInfoHistoryDart>('GetPointerFramePenInfoHistory');
// pointerId : DWORD -> Uint32
// entriesCount : DWORD* in/out -> Pointer<Uint32>
// pointerCount : DWORD* in/out -> Pointer<Uint32>
// penInfo : POINTER_PEN_INFO* optional, out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function GetPointerFramePenInfoHistory(
pointerId: DWORD; // DWORD
entriesCount: Pointer; // DWORD* in/out
pointerCount: Pointer; // DWORD* in/out
penInfo: Pointer // POINTER_PEN_INFO* optional, out
): BOOL; stdcall;
external 'USER32.dll' name 'GetPointerFramePenInfoHistory';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GetPointerFramePenInfoHistory"
c_GetPointerFramePenInfoHistory :: Word32 -> Ptr Word32 -> Ptr Word32 -> Ptr () -> IO CInt
-- pointerId : DWORD -> Word32
-- entriesCount : DWORD* in/out -> Ptr Word32
-- pointerCount : DWORD* in/out -> Ptr Word32
-- penInfo : POINTER_PEN_INFO* optional, out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let getpointerframepeninfohistory =
foreign "GetPointerFramePenInfoHistory"
(uint32_t @-> (ptr uint32_t) @-> (ptr uint32_t) @-> (ptr void) @-> returning int32_t)
(* pointerId : DWORD -> uint32_t *)
(* entriesCount : DWORD* in/out -> (ptr uint32_t) *)
(* pointerCount : DWORD* in/out -> (ptr uint32_t) *)
(* penInfo : POINTER_PEN_INFO* optional, out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library user32 (t "USER32.dll"))
(cffi:use-foreign-library user32)
(cffi:defcfun ("GetPointerFramePenInfoHistory" get-pointer-frame-pen-info-history :convention :stdcall) :int32
(pointer-id :uint32) ; DWORD
(entries-count :pointer) ; DWORD* in/out
(pointer-count :pointer) ; DWORD* in/out
(pen-info :pointer)) ; POINTER_PEN_INFO* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $GetPointerFramePenInfoHistory = Win32::API::More->new('USER32',
'BOOL GetPointerFramePenInfoHistory(DWORD pointerId, LPVOID entriesCount, LPVOID pointerCount, LPVOID penInfo)');
# my $ret = $GetPointerFramePenInfoHistory->Call($pointerId, $entriesCount, $pointerCount, $penInfo);
# pointerId : DWORD -> DWORD
# entriesCount : DWORD* in/out -> LPVOID
# pointerCount : DWORD* in/out -> LPVOID
# penInfo : POINTER_PEN_INFO* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
- f GetPointerFramePenInfo — 同一フレーム内の複数ペン入力情報を取得する。
- f GetPointerPenInfo — 指定したポインタのペン入力情報を取得する。
- f GetPointerPenInfoHistory — 指定したポインタのペン入力情報の履歴を取得する。