-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrop_source.d
69 lines (56 loc) · 1.86 KB
/
drop_source.d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/++
Win32 Drag and Drop demo
++/
module drop_source;
import std.string;
import win32.objidl;
import win32.ole2;
import win32.winbase;
import win32.windef;
import win32.winuser;
import win32.wtypes;
import utils;
import debugLog;
class DropSource : ComObject, IDropSource
{
this() { outLog("CDropSource:this"); }
~this() { outLog("CDropSource:~this"); }
extern (Windows)
override HRESULT QueryInterface(GUID* riid, void** ppv)
{
// outLog("CDropSource:QueryInterface");
if (*riid == IID_IDropSource)
{
*ppv = cast(void*)cast(IUnknown)this;
AddRef();
return S_OK;
}
return super.QueryInterface(riid, ppv);
}
//
// キーやマウスボタンの状態をみて、ドラッグを続けるかやめるかを決める
// Called by OLE whenever Escape/Control/Shift/Mouse buttons have changed.
extern (Windows)
HRESULT QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState)
{
outLog("CDropSource:QueryContinueDrag");
// if the <Escape> key has been pressed since the last call, cancel the drop
if (fEscapePressed == TRUE)
return DRAGDROP_S_CANCEL;
// if the <LeftMouse> button has been released, then do the drop!
if ((grfKeyState & MK_LBUTTON) == 0)
return DRAGDROP_S_DROP;
// continue with the drag-drop
return S_OK;
}
// マウスカーソルの形状を変えたり、特殊効果を出したりするための関数
// DRAGDROP_S_USEDEFAULTCURSORSを返しておけばあとはWindwosが勝手にやってくれます
// Return either S_OK or DRAGDROP_S_USEDEFAULTCURSORS to instruct OLE to use the
// default mouse cursor images
extern (Windows)
HRESULT GiveFeedback(DWORD dwEffect)
{
outLog("CDropSource:GiveFeedback");
return DRAGDROP_S_USEDEFAULTCURSORS;
}
}