Win32 API 日本語リファレンス
ホームUI.WindowsAndMessaging › SetCoalescableTimer

SetCoalescableTimer

関数
許容遅延を指定し合体可能なタイマーを作成する。
DLLUSER32.dll呼出規約winapiSetLastErrorあり対応OSwindows8.0

シグネチャ

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

UINT_PTR SetCoalescableTimer(
    HWND hWnd,   // optional
    UINT_PTR nIDEvent,
    DWORD uElapse,
    TIMERPROC lpTimerFunc,   // optional
    DWORD uToleranceDelay
);

パラメーター

名前方向説明
hWndHWNDinoptionalタイマーを関連付けるウィンドウのハンドル。NULL可。
nIDEventUINT_PTRinタイマー識別子(0以外)。hWndがNULLの場合は無視される。
uElapseDWORDinタイムアウト間隔(ミリ秒)。
lpTimerFuncTIMERPROCinoptionalタイマー発火時に呼ばれるTimerProcへのポインタ。NULLならWM_TIMERがキューに送られる。
uToleranceDelayDWORDinタイマー結合の許容遅延(ミリ秒)。TIMERV_DEFAULT_COALESCINGやTIMERV_NO_COALESCINGも指定可。

戻り値の型: UINT_PTR

各言語での呼び出し定義

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

UINT_PTR SetCoalescableTimer(
    HWND hWnd,   // optional
    UINT_PTR nIDEvent,
    DWORD uElapse,
    TIMERPROC lpTimerFunc,   // optional
    DWORD uToleranceDelay
);
[DllImport("USER32.dll", SetLastError = true, ExactSpelling = true)]
static extern UIntPtr SetCoalescableTimer(
    IntPtr hWnd,   // HWND optional
    UIntPtr nIDEvent,   // UINT_PTR
    uint uElapse,   // DWORD
    IntPtr lpTimerFunc,   // TIMERPROC optional
    uint uToleranceDelay   // DWORD
);
<DllImport("USER32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function SetCoalescableTimer(
    hWnd As IntPtr,   ' HWND optional
    nIDEvent As UIntPtr,   ' UINT_PTR
    uElapse As UInteger,   ' DWORD
    lpTimerFunc As IntPtr,   ' TIMERPROC optional
    uToleranceDelay As UInteger   ' DWORD
) As UIntPtr
End Function
' hWnd : HWND optional
' nIDEvent : UINT_PTR
' uElapse : DWORD
' lpTimerFunc : TIMERPROC optional
' uToleranceDelay : DWORD
Declare PtrSafe Function SetCoalescableTimer Lib "user32" ( _
    ByVal hWnd As LongPtr, _
    ByVal nIDEvent As LongPtr, _
    ByVal uElapse As Long, _
    ByVal lpTimerFunc As LongPtr, _
    ByVal uToleranceDelay As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SetCoalescableTimer = ctypes.windll.user32.SetCoalescableTimer
SetCoalescableTimer.restype = ctypes.c_size_t
SetCoalescableTimer.argtypes = [
    wintypes.HANDLE,  # hWnd : HWND optional
    ctypes.c_size_t,  # nIDEvent : UINT_PTR
    wintypes.DWORD,  # uElapse : DWORD
    ctypes.c_void_p,  # lpTimerFunc : TIMERPROC optional
    wintypes.DWORD,  # uToleranceDelay : DWORD
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('USER32.dll')
SetCoalescableTimer = Fiddle::Function.new(
  lib['SetCoalescableTimer'],
  [
    Fiddle::TYPE_VOIDP,  # hWnd : HWND optional
    Fiddle::TYPE_UINTPTR_T,  # nIDEvent : UINT_PTR
    -Fiddle::TYPE_INT,  # uElapse : DWORD
    Fiddle::TYPE_VOIDP,  # lpTimerFunc : TIMERPROC optional
    -Fiddle::TYPE_INT,  # uToleranceDelay : DWORD
  ],
  Fiddle::TYPE_UINTPTR_T)
#[link(name = "user32")]
extern "system" {
    fn SetCoalescableTimer(
        hWnd: *mut core::ffi::c_void,  // HWND optional
        nIDEvent: usize,  // UINT_PTR
        uElapse: u32,  // DWORD
        lpTimerFunc: *const core::ffi::c_void,  // TIMERPROC optional
        uToleranceDelay: u32  // DWORD
    ) -> usize;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("USER32.dll", SetLastError = true)]
public static extern UIntPtr SetCoalescableTimer(IntPtr hWnd, UIntPtr nIDEvent, uint uElapse, IntPtr lpTimerFunc, uint uToleranceDelay);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_SetCoalescableTimer' -Namespace Win32 -PassThru
# $api::SetCoalescableTimer(hWnd, nIDEvent, uElapse, lpTimerFunc, uToleranceDelay)
#uselib "USER32.dll"
#func global SetCoalescableTimer "SetCoalescableTimer" sptr, sptr, sptr, sptr, sptr
; SetCoalescableTimer hWnd, nIDEvent, uElapse, lpTimerFunc, uToleranceDelay   ; 戻り値は stat
; hWnd : HWND optional -> "sptr"
; nIDEvent : UINT_PTR -> "sptr"
; uElapse : DWORD -> "sptr"
; lpTimerFunc : TIMERPROC optional -> "sptr"
; uToleranceDelay : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "USER32.dll"
#cfunc global SetCoalescableTimer "SetCoalescableTimer" sptr, sptr, int, sptr, int
; res = SetCoalescableTimer(hWnd, nIDEvent, uElapse, lpTimerFunc, uToleranceDelay)
; hWnd : HWND optional -> "sptr"
; nIDEvent : UINT_PTR -> "sptr"
; uElapse : DWORD -> "int"
; lpTimerFunc : TIMERPROC optional -> "sptr"
; uToleranceDelay : DWORD -> "int"
; UINT_PTR SetCoalescableTimer(HWND hWnd, UINT_PTR nIDEvent, DWORD uElapse, TIMERPROC lpTimerFunc, DWORD uToleranceDelay)
#uselib "USER32.dll"
#cfunc global SetCoalescableTimer "SetCoalescableTimer" intptr, intptr, int, intptr, int
; res = SetCoalescableTimer(hWnd, nIDEvent, uElapse, lpTimerFunc, uToleranceDelay)
; hWnd : HWND optional -> "intptr"
; nIDEvent : UINT_PTR -> "intptr"
; uElapse : DWORD -> "int"
; lpTimerFunc : TIMERPROC optional -> "intptr"
; uToleranceDelay : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procSetCoalescableTimer = user32.NewProc("SetCoalescableTimer")
)

// hWnd (HWND optional), nIDEvent (UINT_PTR), uElapse (DWORD), lpTimerFunc (TIMERPROC optional), uToleranceDelay (DWORD)
r1, _, err := procSetCoalescableTimer.Call(
	uintptr(hWnd),
	uintptr(nIDEvent),
	uintptr(uElapse),
	uintptr(lpTimerFunc),
	uintptr(uToleranceDelay),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // UINT_PTR
function SetCoalescableTimer(
  hWnd: THandle;   // HWND optional
  nIDEvent: NativeUInt;   // UINT_PTR
  uElapse: DWORD;   // DWORD
  lpTimerFunc: Pointer;   // TIMERPROC optional
  uToleranceDelay: DWORD   // DWORD
): NativeUInt; stdcall;
  external 'USER32.dll' name 'SetCoalescableTimer';
result := DllCall("USER32\SetCoalescableTimer"
    , "Ptr", hWnd   ; HWND optional
    , "UPtr", nIDEvent   ; UINT_PTR
    , "UInt", uElapse   ; DWORD
    , "Ptr", lpTimerFunc   ; TIMERPROC optional
    , "UInt", uToleranceDelay   ; DWORD
    , "UPtr")   ; return: UINT_PTR
●SetCoalescableTimer(hWnd, nIDEvent, uElapse, lpTimerFunc, uToleranceDelay) = DLL("USER32.dll", "int SetCoalescableTimer(void*, int, dword, void*, dword)")
# 呼び出し: SetCoalescableTimer(hWnd, nIDEvent, uElapse, lpTimerFunc, uToleranceDelay)
# hWnd : HWND optional -> "void*"
# nIDEvent : UINT_PTR -> "int"
# uElapse : DWORD -> "dword"
# lpTimerFunc : TIMERPROC optional -> "void*"
# uToleranceDelay : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。