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予約済み。0を指定する。
cIDsDWORDinpGestureConfig配列の要素数を指定する。
pGestureConfigGESTURECONFIG*in有効・無効にするジェスチャ設定を表すGESTURECONFIG配列へのポインタ。
cbSizeDWORDinGESTURECONFIG構造体1個のバイトサイズを指定する。

戻り値の型: 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 <MarshalAs(UnmanagedType.Bool)> 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)。
const std = @import("std");

extern "user32" fn SetGestureConfig(
    hwnd: ?*anyopaque, // HWND
    dwReserved: u32, // DWORD
    cIDs: u32, // DWORD
    pGestureConfig: [*c]GESTURECONFIG, // GESTURECONFIG*
    cbSize: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;
proc SetGestureConfig(
    hwnd: pointer,  # HWND
    dwReserved: uint32,  # DWORD
    cIDs: uint32,  # DWORD
    pGestureConfig: ptr GESTURECONFIG,  # GESTURECONFIG*
    cbSize: uint32  # DWORD
): int32 {.importc: "SetGestureConfig", stdcall, dynlib: "USER32.dll".}
pragma(lib, "user32");
extern(Windows)
int SetGestureConfig(
    void* hwnd,   // HWND
    uint dwReserved,   // DWORD
    uint cIDs,   // DWORD
    GESTURECONFIG* pGestureConfig,   // GESTURECONFIG*
    uint cbSize   // DWORD
);
ccall((:SetGestureConfig, "USER32.dll"), stdcall, Int32,
      (Ptr{Cvoid}, UInt32, UInt32, Ptr{GESTURECONFIG}, UInt32),
      hwnd, dwReserved, cIDs, pGestureConfig, cbSize)
# hwnd : HWND -> Ptr{Cvoid}
# dwReserved : DWORD -> UInt32
# cIDs : DWORD -> UInt32
# pGestureConfig : GESTURECONFIG* -> Ptr{GESTURECONFIG}
# cbSize : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t SetGestureConfig(
    void* hwnd,
    uint32_t dwReserved,
    uint32_t cIDs,
    void* pGestureConfig,
    uint32_t cbSize);
]]
local user32 = ffi.load("user32")
-- user32.SetGestureConfig(hwnd, dwReserved, cIDs, pGestureConfig, cbSize)
-- hwnd : HWND
-- dwReserved : DWORD
-- cIDs : DWORD
-- pGestureConfig : GESTURECONFIG*
-- cbSize : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('USER32.dll');
const SetGestureConfig = lib.func('__stdcall', 'SetGestureConfig', 'int32_t', ['void *', 'uint32_t', 'uint32_t', 'void *', 'uint32_t']);
// SetGestureConfig(hwnd, dwReserved, cIDs, pGestureConfig, cbSize)
// hwnd : HWND -> 'void *'
// dwReserved : DWORD -> 'uint32_t'
// cIDs : DWORD -> 'uint32_t'
// pGestureConfig : GESTURECONFIG* -> 'void *'
// cbSize : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("USER32.dll", {
  SetGestureConfig: { parameters: ["pointer", "u32", "u32", "pointer", "u32"], result: "i32" },
});
// lib.symbols.SetGestureConfig(hwnd, dwReserved, cIDs, pGestureConfig, cbSize)
// hwnd : HWND -> "pointer"
// dwReserved : DWORD -> "u32"
// cIDs : DWORD -> "u32"
// pGestureConfig : GESTURECONFIG* -> "pointer"
// cbSize : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t SetGestureConfig(
    void* hwnd,
    uint32_t dwReserved,
    uint32_t cIDs,
    void* pGestureConfig,
    uint32_t cbSize);
C, "USER32.dll");
// $ffi->SetGestureConfig(hwnd, dwReserved, cIDs, pGestureConfig, cbSize);
// hwnd : HWND
// dwReserved : DWORD
// cIDs : DWORD
// pGestureConfig : GESTURECONFIG*
// cbSize : DWORD
// 構造体/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 SetGestureConfig(
        Pointer hwnd,   // HWND
        int dwReserved,   // DWORD
        int cIDs,   // DWORD
        Pointer pGestureConfig,   // GESTURECONFIG*
        int cbSize   // DWORD
    );
}
@[Link("user32")]
lib LibUSER32
  fun SetGestureConfig = SetGestureConfig(
    hwnd : Void*,   # HWND
    dwReserved : UInt32,   # DWORD
    cIDs : UInt32,   # DWORD
    pGestureConfig : GESTURECONFIG*,   # GESTURECONFIG*
    cbSize : UInt32   # DWORD
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef SetGestureConfigNative = Int32 Function(Pointer<Void>, Uint32, Uint32, Pointer<Void>, Uint32);
typedef SetGestureConfigDart = int Function(Pointer<Void>, int, int, Pointer<Void>, int);
final SetGestureConfig = DynamicLibrary.open('USER32.dll')
    .lookupFunction<SetGestureConfigNative, SetGestureConfigDart>('SetGestureConfig');
// hwnd : HWND -> Pointer<Void>
// dwReserved : DWORD -> Uint32
// cIDs : DWORD -> Uint32
// pGestureConfig : GESTURECONFIG* -> Pointer<Void>
// cbSize : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function SetGestureConfig(
  hwnd: THandle;   // HWND
  dwReserved: DWORD;   // DWORD
  cIDs: DWORD;   // DWORD
  pGestureConfig: Pointer;   // GESTURECONFIG*
  cbSize: DWORD   // DWORD
): BOOL; stdcall;
  external 'USER32.dll' name 'SetGestureConfig';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "SetGestureConfig"
  c_SetGestureConfig :: Ptr () -> Word32 -> Word32 -> Ptr () -> Word32 -> IO CInt
-- hwnd : HWND -> Ptr ()
-- dwReserved : DWORD -> Word32
-- cIDs : DWORD -> Word32
-- pGestureConfig : GESTURECONFIG* -> Ptr ()
-- cbSize : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let setgestureconfig =
  foreign "SetGestureConfig"
    ((ptr void) @-> uint32_t @-> uint32_t @-> (ptr void) @-> uint32_t @-> returning int32_t)
(* hwnd : HWND -> (ptr void) *)
(* dwReserved : DWORD -> uint32_t *)
(* cIDs : DWORD -> uint32_t *)
(* pGestureConfig : GESTURECONFIG* -> (ptr void) *)
(* cbSize : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library user32 (t "USER32.dll"))
(cffi:use-foreign-library user32)

(cffi:defcfun ("SetGestureConfig" set-gesture-config :convention :stdcall) :int32
  (hwnd :pointer)   ; HWND
  (dw-reserved :uint32)   ; DWORD
  (c-ids :uint32)   ; DWORD
  (p-gesture-config :pointer)   ; GESTURECONFIG*
  (cb-size :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SetGestureConfig = Win32::API::More->new('USER32',
    'BOOL SetGestureConfig(HANDLE hwnd, DWORD dwReserved, DWORD cIDs, LPVOID pGestureConfig, DWORD cbSize)');
# my $ret = $SetGestureConfig->Call($hwnd, $dwReserved, $cIDs, $pGestureConfig, $cbSize);
# hwnd : HWND -> HANDLE
# dwReserved : DWORD -> DWORD
# cIDs : DWORD -> DWORD
# pGestureConfig : GESTURECONFIG* -> LPVOID
# cbSize : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型