DragQueryPoint
関数ファイルがドロップされた位置の座標を取得する。
シグネチャ
// SHELL32.dll
#include <windows.h>
BOOL DragQueryPoint(
HDROP hDrop,
POINT* ppt
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hDrop | HDROP | in | ドロップされたファイルを記述するドロップ構造体のハンドル。 |
| ppt | POINT* | out | POINT 構造体へのポインター。この関数が正常に終了すると、ファイルがドロップされた時点のマウスポインターの座標を受け取ります。 |
戻り値の型: BOOL
公式ドキュメント
ドラッグアンドドロップ操作でファイルがドロップされた時点のマウスポインターの位置を取得します。
戻り値
型: BOOL
ウィンドウのクライアント領域内でドロップが発生した場合は TRUE、それ以外の場合は FALSE。
解説(Remarks)
座標が返されるウィンドウは、WM_DROPFILES メッセージを受け取ったウィンドウです。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// SHELL32.dll
#include <windows.h>
BOOL DragQueryPoint(
HDROP hDrop,
POINT* ppt
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SHELL32.dll", ExactSpelling = true)]
static extern bool DragQueryPoint(
IntPtr hDrop, // HDROP
IntPtr ppt // POINT* out
);<DllImport("SHELL32.dll", ExactSpelling:=True)>
Public Shared Function DragQueryPoint(
hDrop As IntPtr, ' HDROP
ppt As IntPtr ' POINT* out
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' hDrop : HDROP
' ppt : POINT* out
Declare PtrSafe Function DragQueryPoint Lib "shell32" ( _
ByVal hDrop As LongPtr, _
ByVal ppt As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DragQueryPoint = ctypes.windll.shell32.DragQueryPoint
DragQueryPoint.restype = wintypes.BOOL
DragQueryPoint.argtypes = [
wintypes.HANDLE, # hDrop : HDROP
ctypes.c_void_p, # ppt : POINT* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SHELL32.dll')
DragQueryPoint = Fiddle::Function.new(
lib['DragQueryPoint'],
[
Fiddle::TYPE_VOIDP, # hDrop : HDROP
Fiddle::TYPE_VOIDP, # ppt : POINT* out
],
Fiddle::TYPE_INT)#[link(name = "shell32")]
extern "system" {
fn DragQueryPoint(
hDrop: *mut core::ffi::c_void, // HDROP
ppt: *mut POINT // POINT* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SHELL32.dll")]
public static extern bool DragQueryPoint(IntPtr hDrop, IntPtr ppt);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHELL32_DragQueryPoint' -Namespace Win32 -PassThru
# $api::DragQueryPoint(hDrop, ppt)#uselib "SHELL32.dll"
#func global DragQueryPoint "DragQueryPoint" sptr, sptr
; DragQueryPoint hDrop, varptr(ppt) ; 戻り値は stat
; hDrop : HDROP -> "sptr"
; ppt : POINT* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SHELL32.dll" #cfunc global DragQueryPoint "DragQueryPoint" sptr, var ; res = DragQueryPoint(hDrop, ppt) ; hDrop : HDROP -> "sptr" ; ppt : POINT* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SHELL32.dll" #cfunc global DragQueryPoint "DragQueryPoint" sptr, sptr ; res = DragQueryPoint(hDrop, varptr(ppt)) ; hDrop : HDROP -> "sptr" ; ppt : POINT* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL DragQueryPoint(HDROP hDrop, POINT* ppt) #uselib "SHELL32.dll" #cfunc global DragQueryPoint "DragQueryPoint" intptr, var ; res = DragQueryPoint(hDrop, ppt) ; hDrop : HDROP -> "intptr" ; ppt : POINT* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL DragQueryPoint(HDROP hDrop, POINT* ppt) #uselib "SHELL32.dll" #cfunc global DragQueryPoint "DragQueryPoint" intptr, intptr ; res = DragQueryPoint(hDrop, varptr(ppt)) ; hDrop : HDROP -> "intptr" ; ppt : POINT* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
shell32 = windows.NewLazySystemDLL("SHELL32.dll")
procDragQueryPoint = shell32.NewProc("DragQueryPoint")
)
// hDrop (HDROP), ppt (POINT* out)
r1, _, err := procDragQueryPoint.Call(
uintptr(hDrop),
uintptr(ppt),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction DragQueryPoint(
hDrop: THandle; // HDROP
ppt: Pointer // POINT* out
): BOOL; stdcall;
external 'SHELL32.dll' name 'DragQueryPoint';result := DllCall("SHELL32\DragQueryPoint"
, "Ptr", hDrop ; HDROP
, "Ptr", ppt ; POINT* out
, "Int") ; return: BOOL●DragQueryPoint(hDrop, ppt) = DLL("SHELL32.dll", "bool DragQueryPoint(void*, void*)")
# 呼び出し: DragQueryPoint(hDrop, ppt)
# hDrop : HDROP -> "void*"
# ppt : POINT* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "shell32" fn DragQueryPoint(
hDrop: ?*anyopaque, // HDROP
ppt: [*c]POINT // POINT* out
) callconv(std.os.windows.WINAPI) i32;proc DragQueryPoint(
hDrop: pointer, # HDROP
ppt: ptr POINT # POINT* out
): int32 {.importc: "DragQueryPoint", stdcall, dynlib: "SHELL32.dll".}pragma(lib, "shell32");
extern(Windows)
int DragQueryPoint(
void* hDrop, // HDROP
POINT* ppt // POINT* out
);ccall((:DragQueryPoint, "SHELL32.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{POINT}),
hDrop, ppt)
# hDrop : HDROP -> Ptr{Cvoid}
# ppt : POINT* out -> Ptr{POINT}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t DragQueryPoint(
void* hDrop,
void* ppt);
]]
local shell32 = ffi.load("shell32")
-- shell32.DragQueryPoint(hDrop, ppt)
-- hDrop : HDROP
-- ppt : POINT* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('SHELL32.dll');
const DragQueryPoint = lib.func('__stdcall', 'DragQueryPoint', 'int32_t', ['void *', 'void *']);
// DragQueryPoint(hDrop, ppt)
// hDrop : HDROP -> 'void *'
// ppt : POINT* out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("SHELL32.dll", {
DragQueryPoint: { parameters: ["pointer", "pointer"], result: "i32" },
});
// lib.symbols.DragQueryPoint(hDrop, ppt)
// hDrop : HDROP -> "pointer"
// ppt : POINT* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t DragQueryPoint(
void* hDrop,
void* ppt);
C, "SHELL32.dll");
// $ffi->DragQueryPoint(hDrop, ppt);
// hDrop : HDROP
// ppt : POINT* 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 Shell32 extends StdCallLibrary {
Shell32 INSTANCE = Native.load("shell32", Shell32.class);
boolean DragQueryPoint(
Pointer hDrop, // HDROP
Pointer ppt // POINT* out
);
}@[Link("shell32")]
lib LibSHELL32
fun DragQueryPoint = DragQueryPoint(
hDrop : Void*, # HDROP
ppt : POINT* # POINT* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef DragQueryPointNative = Int32 Function(Pointer<Void>, Pointer<Void>);
typedef DragQueryPointDart = int Function(Pointer<Void>, Pointer<Void>);
final DragQueryPoint = DynamicLibrary.open('SHELL32.dll')
.lookupFunction<DragQueryPointNative, DragQueryPointDart>('DragQueryPoint');
// hDrop : HDROP -> Pointer<Void>
// ppt : POINT* out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function DragQueryPoint(
hDrop: THandle; // HDROP
ppt: Pointer // POINT* out
): BOOL; stdcall;
external 'SHELL32.dll' name 'DragQueryPoint';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "DragQueryPoint"
c_DragQueryPoint :: Ptr () -> Ptr () -> IO CInt
-- hDrop : HDROP -> Ptr ()
-- ppt : POINT* out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let dragquerypoint =
foreign "DragQueryPoint"
((ptr void) @-> (ptr void) @-> returning int32_t)
(* hDrop : HDROP -> (ptr void) *)
(* ppt : POINT* out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library shell32 (t "SHELL32.dll"))
(cffi:use-foreign-library shell32)
(cffi:defcfun ("DragQueryPoint" drag-query-point :convention :stdcall) :int32
(h-drop :pointer) ; HDROP
(ppt :pointer)) ; POINT* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $DragQueryPoint = Win32::API::More->new('SHELL32',
'BOOL DragQueryPoint(HANDLE hDrop, LPVOID ppt)');
# my $ret = $DragQueryPoint->Call($hDrop, $ppt);
# hDrop : HDROP -> HANDLE
# ppt : POINT* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
公式の関連項目
- f DragQueryFileW — ドロップされたファイル名(Unicode)や個数を取得する。
使用する型