RegisterForTooltipDismissNotification
関数シグネチャ
// USER32.dll
#include <windows.h>
BOOL RegisterForTooltipDismissNotification(
HWND hWnd,
TOOLTIP_DISMISS_FLAGS tdFlags
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hWnd | HWND | in | WM_TOOLTIPDISMISS メッセージを受け取るウィンドウのハンドル。 |
| tdFlags | TOOLTIP_DISMISS_FLAGS | in | ウィンドウを登録するか登録解除するかを指定する列挙体の値。登録するには TDF_REGISTER、登録解除するには TDF_UNREGISTER を指定します。 |
戻り値の型: BOOL
公式ドキュメント
アプリまたは UI フレームワークが、ツールチップウィンドウを閉じる通知を受け取るために、ウィンドウの登録および登録解除を行えるようにします。
戻り値
ウィンドウの登録または登録解除に成功した場合は TRUE、それ以外の場合は FALSE を返します。(「解説」を参照してください。)
解説(Remarks)
この関数は、ツールチップをサポートするアプリやフレームワークが登録および登録解除を行えるようにすることで、ツールチップのアクセシビリティを向上させます。システムが表示中のすべてのツールチップを閉じる必要がある場合、登録したウィンドウは WM_TOOLTIPDISMISS メッセージによって通知されます。
アプリは、ツールチップを表示するたびにこの通知に登録し、WM_TOOLTIPDISMISS メッセージに応じてツールチップを非表示にする必要があります。マウス操作など他の理由でツールチップが非表示になった場合、アプリは登録を解除する必要があります。
ツールチップを閉じるためのシステム定義のトリガーには、Ctrl キー単独の解放や Ctrl+Shift+F10 などがあります。(トリガーのセットは将来変更される可能性があります。)
この関数は、ツールチップウィンドウの HWND、または子ツールチップを持つアプリウィンドウの HWND のいずれかを受け取ります。
- ツールチップ HWND 自体が登録される場合、そのツールチップウィンドウは、表示時に登録を行い、WM_TOOLTIPDISMISS メッセージを受け取った時点で閉じることが期待されます。
- アプリ HWND が自身のツールチップに代わって登録する場合、そのアプリウィンドウは、ツールチップの表示時に登録を行い、WM_TOOLTIPDISMISS メッセージを受け取った時点で自身のすべてのツールチップを閉じることが期待されます。
ツールチップウィンドウまたはアプリウィンドウは、ツールチップが表示されるたびにこの関数を呼び出して登録することが期待されます。登録されたウィンドウは、WM_TOOLTIPDISMISS がポストされると自動的に登録解除されます。
TDF_UNREGISTER フラグは、アプリケーションまたはフレームワークの判断(カーソルを「セーフゾーン」の外に移動した場合など)によってツールチップウィンドウが閉じられたときに、ウィンドウを明示的に登録解除するために使用します。ウィンドウが自動的に登録解除された後に、アプリまたはフレームワークが TDF_UNREGISTER を指定して RegisterForTooltipDismissNotification を呼び出すと、関数は FALSE を返します。これは今後の登録には影響しません。
戻り値
この関数に渡される HWND は、呼び出し元のプロセスが所有している必要があります。そうでない場合、関数は FALSE を返します。
TDF_REGISTER と呼び出し元プロセスに属するウィンドウを指定して呼び出した場合、ウィンドウの登録に成功すると TRUE を返し、ウィンドウが既に登録済みであった場合は FALSE を返します。いずれの場合も、そのウィンドウは登録済みとして扱われます。
TDF_UNREGISTER と呼び出し元プロセスに属するウィンドウを指定して呼び出した場合、ウィンドウの登録解除に成功すると TRUE を返し、ウィンドウが現在登録されていなかった場合は FALSE を返します。いずれの場合も、そのウィンドウは登録解除済みとして扱われます。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// USER32.dll
#include <windows.h>
BOOL RegisterForTooltipDismissNotification(
HWND hWnd,
TOOLTIP_DISMISS_FLAGS tdFlags
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", ExactSpelling = true)]
static extern bool RegisterForTooltipDismissNotification(
IntPtr hWnd, // HWND
int tdFlags // TOOLTIP_DISMISS_FLAGS
);<DllImport("USER32.dll", ExactSpelling:=True)>
Public Shared Function RegisterForTooltipDismissNotification(
hWnd As IntPtr, ' HWND
tdFlags As Integer ' TOOLTIP_DISMISS_FLAGS
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' hWnd : HWND
' tdFlags : TOOLTIP_DISMISS_FLAGS
Declare PtrSafe Function RegisterForTooltipDismissNotification Lib "user32" ( _
ByVal hWnd As LongPtr, _
ByVal tdFlags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
RegisterForTooltipDismissNotification = ctypes.windll.user32.RegisterForTooltipDismissNotification
RegisterForTooltipDismissNotification.restype = wintypes.BOOL
RegisterForTooltipDismissNotification.argtypes = [
wintypes.HANDLE, # hWnd : HWND
ctypes.c_int, # tdFlags : TOOLTIP_DISMISS_FLAGS
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USER32.dll')
RegisterForTooltipDismissNotification = Fiddle::Function.new(
lib['RegisterForTooltipDismissNotification'],
[
Fiddle::TYPE_VOIDP, # hWnd : HWND
Fiddle::TYPE_INT, # tdFlags : TOOLTIP_DISMISS_FLAGS
],
Fiddle::TYPE_INT)#[link(name = "user32")]
extern "system" {
fn RegisterForTooltipDismissNotification(
hWnd: *mut core::ffi::c_void, // HWND
tdFlags: i32 // TOOLTIP_DISMISS_FLAGS
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll")]
public static extern bool RegisterForTooltipDismissNotification(IntPtr hWnd, int tdFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_RegisterForTooltipDismissNotification' -Namespace Win32 -PassThru
# $api::RegisterForTooltipDismissNotification(hWnd, tdFlags)#uselib "USER32.dll"
#func global RegisterForTooltipDismissNotification "RegisterForTooltipDismissNotification" sptr, sptr
; RegisterForTooltipDismissNotification hWnd, tdFlags ; 戻り値は stat
; hWnd : HWND -> "sptr"
; tdFlags : TOOLTIP_DISMISS_FLAGS -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "USER32.dll"
#cfunc global RegisterForTooltipDismissNotification "RegisterForTooltipDismissNotification" sptr, int
; res = RegisterForTooltipDismissNotification(hWnd, tdFlags)
; hWnd : HWND -> "sptr"
; tdFlags : TOOLTIP_DISMISS_FLAGS -> "int"; BOOL RegisterForTooltipDismissNotification(HWND hWnd, TOOLTIP_DISMISS_FLAGS tdFlags)
#uselib "USER32.dll"
#cfunc global RegisterForTooltipDismissNotification "RegisterForTooltipDismissNotification" intptr, int
; res = RegisterForTooltipDismissNotification(hWnd, tdFlags)
; hWnd : HWND -> "intptr"
; tdFlags : TOOLTIP_DISMISS_FLAGS -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
user32 = windows.NewLazySystemDLL("USER32.dll")
procRegisterForTooltipDismissNotification = user32.NewProc("RegisterForTooltipDismissNotification")
)
// hWnd (HWND), tdFlags (TOOLTIP_DISMISS_FLAGS)
r1, _, err := procRegisterForTooltipDismissNotification.Call(
uintptr(hWnd),
uintptr(tdFlags),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction RegisterForTooltipDismissNotification(
hWnd: THandle; // HWND
tdFlags: Integer // TOOLTIP_DISMISS_FLAGS
): BOOL; stdcall;
external 'USER32.dll' name 'RegisterForTooltipDismissNotification';result := DllCall("USER32\RegisterForTooltipDismissNotification"
, "Ptr", hWnd ; HWND
, "Int", tdFlags ; TOOLTIP_DISMISS_FLAGS
, "Int") ; return: BOOL●RegisterForTooltipDismissNotification(hWnd, tdFlags) = DLL("USER32.dll", "bool RegisterForTooltipDismissNotification(void*, int)")
# 呼び出し: RegisterForTooltipDismissNotification(hWnd, tdFlags)
# hWnd : HWND -> "void*"
# tdFlags : TOOLTIP_DISMISS_FLAGS -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "user32" fn RegisterForTooltipDismissNotification(
hWnd: ?*anyopaque, // HWND
tdFlags: i32 // TOOLTIP_DISMISS_FLAGS
) callconv(std.os.windows.WINAPI) i32;proc RegisterForTooltipDismissNotification(
hWnd: pointer, # HWND
tdFlags: int32 # TOOLTIP_DISMISS_FLAGS
): int32 {.importc: "RegisterForTooltipDismissNotification", stdcall, dynlib: "USER32.dll".}pragma(lib, "user32");
extern(Windows)
int RegisterForTooltipDismissNotification(
void* hWnd, // HWND
int tdFlags // TOOLTIP_DISMISS_FLAGS
);ccall((:RegisterForTooltipDismissNotification, "USER32.dll"), stdcall, Int32,
(Ptr{Cvoid}, Int32),
hWnd, tdFlags)
# hWnd : HWND -> Ptr{Cvoid}
# tdFlags : TOOLTIP_DISMISS_FLAGS -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t RegisterForTooltipDismissNotification(
void* hWnd,
int32_t tdFlags);
]]
local user32 = ffi.load("user32")
-- user32.RegisterForTooltipDismissNotification(hWnd, tdFlags)
-- hWnd : HWND
-- tdFlags : TOOLTIP_DISMISS_FLAGS
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('USER32.dll');
const RegisterForTooltipDismissNotification = lib.func('__stdcall', 'RegisterForTooltipDismissNotification', 'int32_t', ['void *', 'int32_t']);
// RegisterForTooltipDismissNotification(hWnd, tdFlags)
// hWnd : HWND -> 'void *'
// tdFlags : TOOLTIP_DISMISS_FLAGS -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("USER32.dll", {
RegisterForTooltipDismissNotification: { parameters: ["pointer", "i32"], result: "i32" },
});
// lib.symbols.RegisterForTooltipDismissNotification(hWnd, tdFlags)
// hWnd : HWND -> "pointer"
// tdFlags : TOOLTIP_DISMISS_FLAGS -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t RegisterForTooltipDismissNotification(
void* hWnd,
int32_t tdFlags);
C, "USER32.dll");
// $ffi->RegisterForTooltipDismissNotification(hWnd, tdFlags);
// hWnd : HWND
// tdFlags : TOOLTIP_DISMISS_FLAGS
// 構造体/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 RegisterForTooltipDismissNotification(
Pointer hWnd, // HWND
int tdFlags // TOOLTIP_DISMISS_FLAGS
);
}@[Link("user32")]
lib LibUSER32
fun RegisterForTooltipDismissNotification = RegisterForTooltipDismissNotification(
hWnd : Void*, # HWND
tdFlags : Int32 # TOOLTIP_DISMISS_FLAGS
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef RegisterForTooltipDismissNotificationNative = Int32 Function(Pointer<Void>, Int32);
typedef RegisterForTooltipDismissNotificationDart = int Function(Pointer<Void>, int);
final RegisterForTooltipDismissNotification = DynamicLibrary.open('USER32.dll')
.lookupFunction<RegisterForTooltipDismissNotificationNative, RegisterForTooltipDismissNotificationDart>('RegisterForTooltipDismissNotification');
// hWnd : HWND -> Pointer<Void>
// tdFlags : TOOLTIP_DISMISS_FLAGS -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function RegisterForTooltipDismissNotification(
hWnd: THandle; // HWND
tdFlags: Integer // TOOLTIP_DISMISS_FLAGS
): BOOL; stdcall;
external 'USER32.dll' name 'RegisterForTooltipDismissNotification';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "RegisterForTooltipDismissNotification"
c_RegisterForTooltipDismissNotification :: Ptr () -> Int32 -> IO CInt
-- hWnd : HWND -> Ptr ()
-- tdFlags : TOOLTIP_DISMISS_FLAGS -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let registerfortooltipdismissnotification =
foreign "RegisterForTooltipDismissNotification"
((ptr void) @-> int32_t @-> returning int32_t)
(* hWnd : HWND -> (ptr void) *)
(* tdFlags : TOOLTIP_DISMISS_FLAGS -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library user32 (t "USER32.dll"))
(cffi:use-foreign-library user32)
(cffi:defcfun ("RegisterForTooltipDismissNotification" register-for-tooltip-dismiss-notification :convention :stdcall) :int32
(h-wnd :pointer) ; HWND
(td-flags :int32)) ; TOOLTIP_DISMISS_FLAGS
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $RegisterForTooltipDismissNotification = Win32::API::More->new('USER32',
'BOOL RegisterForTooltipDismissNotification(HANDLE hWnd, int tdFlags)');
# my $ret = $RegisterForTooltipDismissNotification->Call($hWnd, $tdFlags);
# hWnd : HWND -> HANDLE
# tdFlags : TOOLTIP_DISMISS_FLAGS -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。