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

SetGestureConfig

関数
ウィンドウで有効にするジェスチャの構成を設定する。
DLLUSER32.dll呼出規約winapiSetLastErrorあり対応OSWindows 7 以降

シグネチャ

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

BOOL SetGestureConfig(
    HWND hwnd,
    DWORD dwReserved,
    DWORD cIDs,
    GESTURECONFIG* pGestureConfig,
    DWORD cbSize
);

パラメーター

名前方向
hwndHWNDin
dwReservedDWORDin
cIDsDWORDin
pGestureConfigGESTURECONFIG*in
cbSizeDWORDin

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL SetGestureConfig(
    HWND hwnd,
    DWORD dwReserved,
    DWORD cIDs,
    GESTURECONFIG* pGestureConfig,
    DWORD cbSize
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool SetGestureConfig(
    IntPtr hwnd,   // HWND
    uint dwReserved,   // DWORD
    uint cIDs,   // DWORD
    IntPtr pGestureConfig,   // GESTURECONFIG*
    uint cbSize   // DWORD
);
<DllImport("USER32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetGestureConfig(
    hwnd As IntPtr,   ' HWND
    dwReserved As UInteger,   ' DWORD
    cIDs As UInteger,   ' DWORD
    pGestureConfig As IntPtr,   ' GESTURECONFIG*
    cbSize As UInteger   ' DWORD
) As Boolean
End Function
' hwnd : HWND
' dwReserved : DWORD
' cIDs : DWORD
' pGestureConfig : GESTURECONFIG*
' cbSize : DWORD
Declare PtrSafe Function SetGestureConfig Lib "user32" ( _
    ByVal hwnd As LongPtr, _
    ByVal dwReserved As Long, _
    ByVal cIDs As Long, _
    ByVal pGestureConfig As LongPtr, _
    ByVal cbSize As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SetGestureConfig = ctypes.windll.user32.SetGestureConfig
SetGestureConfig.restype = wintypes.BOOL
SetGestureConfig.argtypes = [
    wintypes.HANDLE,  # hwnd : HWND
    wintypes.DWORD,  # dwReserved : DWORD
    wintypes.DWORD,  # cIDs : DWORD
    ctypes.c_void_p,  # pGestureConfig : GESTURECONFIG*
    wintypes.DWORD,  # cbSize : DWORD
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('USER32.dll')
SetGestureConfig = Fiddle::Function.new(
  lib['SetGestureConfig'],
  [
    Fiddle::TYPE_VOIDP,  # hwnd : HWND
    -Fiddle::TYPE_INT,  # dwReserved : DWORD
    -Fiddle::TYPE_INT,  # cIDs : DWORD
    Fiddle::TYPE_VOIDP,  # pGestureConfig : GESTURECONFIG*
    -Fiddle::TYPE_INT,  # cbSize : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "user32")]
extern "system" {
    fn SetGestureConfig(
        hwnd: *mut core::ffi::c_void,  // HWND
        dwReserved: u32,  // DWORD
        cIDs: u32,  // DWORD
        pGestureConfig: *mut GESTURECONFIG,  // GESTURECONFIG*
        cbSize: u32  // DWORD
    ) -> 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 SetGestureConfig(IntPtr hwnd, uint dwReserved, uint cIDs, IntPtr pGestureConfig, uint cbSize);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_SetGestureConfig' -Namespace Win32 -PassThru
# $api::SetGestureConfig(hwnd, dwReserved, cIDs, pGestureConfig, cbSize)
#uselib "USER32.dll"
#func global SetGestureConfig "SetGestureConfig" sptr, sptr, sptr, sptr, sptr
; SetGestureConfig hwnd, dwReserved, cIDs, varptr(pGestureConfig), cbSize   ; 戻り値は stat
; hwnd : HWND -> "sptr"
; dwReserved : DWORD -> "sptr"
; cIDs : DWORD -> "sptr"
; pGestureConfig : GESTURECONFIG* -> "sptr"
; cbSize : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "USER32.dll"
#cfunc global SetGestureConfig "SetGestureConfig" sptr, int, int, var, int
; res = SetGestureConfig(hwnd, dwReserved, cIDs, pGestureConfig, cbSize)
; hwnd : HWND -> "sptr"
; dwReserved : DWORD -> "int"
; cIDs : DWORD -> "int"
; pGestureConfig : GESTURECONFIG* -> "var"
; cbSize : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL SetGestureConfig(HWND hwnd, DWORD dwReserved, DWORD cIDs, GESTURECONFIG* pGestureConfig, DWORD cbSize)
#uselib "USER32.dll"
#cfunc global SetGestureConfig "SetGestureConfig" intptr, int, int, var, int
; res = SetGestureConfig(hwnd, dwReserved, cIDs, pGestureConfig, cbSize)
; hwnd : HWND -> "intptr"
; dwReserved : DWORD -> "int"
; cIDs : DWORD -> "int"
; pGestureConfig : GESTURECONFIG* -> "var"
; cbSize : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procSetGestureConfig = user32.NewProc("SetGestureConfig")
)

// hwnd (HWND), dwReserved (DWORD), cIDs (DWORD), pGestureConfig (GESTURECONFIG*), cbSize (DWORD)
r1, _, err := procSetGestureConfig.Call(
	uintptr(hwnd),
	uintptr(dwReserved),
	uintptr(cIDs),
	uintptr(pGestureConfig),
	uintptr(cbSize),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function SetGestureConfig(
  hwnd: THandle;   // HWND
  dwReserved: DWORD;   // DWORD
  cIDs: DWORD;   // DWORD
  pGestureConfig: Pointer;   // GESTURECONFIG*
  cbSize: DWORD   // DWORD
): BOOL; stdcall;
  external 'USER32.dll' name 'SetGestureConfig';
result := DllCall("USER32\SetGestureConfig"
    , "Ptr", hwnd   ; HWND
    , "UInt", dwReserved   ; DWORD
    , "UInt", cIDs   ; DWORD
    , "Ptr", pGestureConfig   ; GESTURECONFIG*
    , "UInt", cbSize   ; DWORD
    , "Int")   ; return: BOOL
●SetGestureConfig(hwnd, dwReserved, cIDs, pGestureConfig, cbSize) = DLL("USER32.dll", "bool SetGestureConfig(void*, dword, dword, void*, dword)")
# 呼び出し: SetGestureConfig(hwnd, dwReserved, cIDs, pGestureConfig, cbSize)
# hwnd : HWND -> "void*"
# dwReserved : DWORD -> "dword"
# cIDs : DWORD -> "dword"
# pGestureConfig : GESTURECONFIG* -> "void*"
# cbSize : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。