ホーム › System.Ole › DoDragDrop
DoDragDrop
関数ドラッグアンドドロップ操作を実行しその効果を返す。
シグネチャ
// OLE32.dll
#include <windows.h>
HRESULT DoDragDrop(
IDataObject* pDataObj,
IDropSource* pDropSource,
DROPEFFECT dwOKEffects,
DROPEFFECT* pdwEffect
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pDataObj | IDataObject* | in |
| pDropSource | IDropSource* | in |
| dwOKEffects | DROPEFFECT | in |
| pdwEffect | DROPEFFECT* | out |
戻り値の型: HRESULT
各言語での呼び出し定義
// OLE32.dll
#include <windows.h>
HRESULT DoDragDrop(
IDataObject* pDataObj,
IDropSource* pDropSource,
DROPEFFECT dwOKEffects,
DROPEFFECT* pdwEffect
);[DllImport("OLE32.dll", ExactSpelling = true)]
static extern int DoDragDrop(
IntPtr pDataObj, // IDataObject*
IntPtr pDropSource, // IDropSource*
uint dwOKEffects, // DROPEFFECT
out uint pdwEffect // DROPEFFECT* out
);<DllImport("OLE32.dll", ExactSpelling:=True)>
Public Shared Function DoDragDrop(
pDataObj As IntPtr, ' IDataObject*
pDropSource As IntPtr, ' IDropSource*
dwOKEffects As UInteger, ' DROPEFFECT
<Out> ByRef pdwEffect As UInteger ' DROPEFFECT* out
) As Integer
End Function' pDataObj : IDataObject*
' pDropSource : IDropSource*
' dwOKEffects : DROPEFFECT
' pdwEffect : DROPEFFECT* out
Declare PtrSafe Function DoDragDrop Lib "ole32" ( _
ByVal pDataObj As LongPtr, _
ByVal pDropSource As LongPtr, _
ByVal dwOKEffects As Long, _
ByRef pdwEffect As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DoDragDrop = ctypes.windll.ole32.DoDragDrop
DoDragDrop.restype = ctypes.c_int
DoDragDrop.argtypes = [
ctypes.c_void_p, # pDataObj : IDataObject*
ctypes.c_void_p, # pDropSource : IDropSource*
wintypes.DWORD, # dwOKEffects : DROPEFFECT
ctypes.c_void_p, # pdwEffect : DROPEFFECT* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('OLE32.dll')
DoDragDrop = Fiddle::Function.new(
lib['DoDragDrop'],
[
Fiddle::TYPE_VOIDP, # pDataObj : IDataObject*
Fiddle::TYPE_VOIDP, # pDropSource : IDropSource*
-Fiddle::TYPE_INT, # dwOKEffects : DROPEFFECT
Fiddle::TYPE_VOIDP, # pdwEffect : DROPEFFECT* out
],
Fiddle::TYPE_INT)#[link(name = "ole32")]
extern "system" {
fn DoDragDrop(
pDataObj: *mut core::ffi::c_void, // IDataObject*
pDropSource: *mut core::ffi::c_void, // IDropSource*
dwOKEffects: u32, // DROPEFFECT
pdwEffect: *mut u32 // DROPEFFECT* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("OLE32.dll")]
public static extern int DoDragDrop(IntPtr pDataObj, IntPtr pDropSource, uint dwOKEffects, out uint pdwEffect);
"@
$api = Add-Type -MemberDefinition $sig -Name 'OLE32_DoDragDrop' -Namespace Win32 -PassThru
# $api::DoDragDrop(pDataObj, pDropSource, dwOKEffects, pdwEffect)#uselib "OLE32.dll"
#func global DoDragDrop "DoDragDrop" sptr, sptr, sptr, sptr
; DoDragDrop pDataObj, pDropSource, dwOKEffects, pdwEffect ; 戻り値は stat
; pDataObj : IDataObject* -> "sptr"
; pDropSource : IDropSource* -> "sptr"
; dwOKEffects : DROPEFFECT -> "sptr"
; pdwEffect : DROPEFFECT* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "OLE32.dll"
#cfunc global DoDragDrop "DoDragDrop" sptr, sptr, int, int
; res = DoDragDrop(pDataObj, pDropSource, dwOKEffects, pdwEffect)
; pDataObj : IDataObject* -> "sptr"
; pDropSource : IDropSource* -> "sptr"
; dwOKEffects : DROPEFFECT -> "int"
; pdwEffect : DROPEFFECT* out -> "int"; HRESULT DoDragDrop(IDataObject* pDataObj, IDropSource* pDropSource, DROPEFFECT dwOKEffects, DROPEFFECT* pdwEffect)
#uselib "OLE32.dll"
#cfunc global DoDragDrop "DoDragDrop" intptr, intptr, int, int
; res = DoDragDrop(pDataObj, pDropSource, dwOKEffects, pdwEffect)
; pDataObj : IDataObject* -> "intptr"
; pDropSource : IDropSource* -> "intptr"
; dwOKEffects : DROPEFFECT -> "int"
; pdwEffect : DROPEFFECT* out -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
ole32 = windows.NewLazySystemDLL("OLE32.dll")
procDoDragDrop = ole32.NewProc("DoDragDrop")
)
// pDataObj (IDataObject*), pDropSource (IDropSource*), dwOKEffects (DROPEFFECT), pdwEffect (DROPEFFECT* out)
r1, _, err := procDoDragDrop.Call(
uintptr(pDataObj),
uintptr(pDropSource),
uintptr(dwOKEffects),
uintptr(pdwEffect),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction DoDragDrop(
pDataObj: Pointer; // IDataObject*
pDropSource: Pointer; // IDropSource*
dwOKEffects: DWORD; // DROPEFFECT
pdwEffect: Pointer // DROPEFFECT* out
): Integer; stdcall;
external 'OLE32.dll' name 'DoDragDrop';result := DllCall("OLE32\DoDragDrop"
, "Ptr", pDataObj ; IDataObject*
, "Ptr", pDropSource ; IDropSource*
, "UInt", dwOKEffects ; DROPEFFECT
, "Ptr", pdwEffect ; DROPEFFECT* out
, "Int") ; return: HRESULT●DoDragDrop(pDataObj, pDropSource, dwOKEffects, pdwEffect) = DLL("OLE32.dll", "int DoDragDrop(void*, void*, dword, void*)")
# 呼び出し: DoDragDrop(pDataObj, pDropSource, dwOKEffects, pdwEffect)
# pDataObj : IDataObject* -> "void*"
# pDropSource : IDropSource* -> "void*"
# dwOKEffects : DROPEFFECT -> "dword"
# pdwEffect : DROPEFFECT* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。