-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwbidropsource.c
More file actions
97 lines (75 loc) · 1.91 KB
/
wbidropsource.c
File metadata and controls
97 lines (75 loc) · 1.91 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#ifndef WBDED_INC
#include "wbded.h"
#endif
static ULONG STDMETHODCALLTYPE
idropsource_addref (WB_IDropSource *This)
{
// increment object reference count
return InterlockedIncrement(&This->m_lRefCount);
}
static ULONG STDMETHODCALLTYPE
idropsource_release (WB_IDropSource *This)
{
LONG count = InterlockedDecrement(&This->m_lRefCount);
if(count == 0)
{
g_free (This);
return 0;
}
else
{
return count;
}
}
static ULONG STDMETHODCALLTYPE
idropsource_queryinterface (WB_IDropSource *This, REFIID riid, void **ppvObject)
{
if (IsEqualGUID (riid, &IID_IUnknown) || IsEqualGUID (riid, &IID_IDropSource))
{
idropsource_addref (This);
*ppvObject = This;
return S_OK;
}
else
{
*ppvObject = 0;
return E_NOINTERFACE;
}
}
static ULONG STDMETHODCALLTYPE
idropsource_querycontinuedrag(WB_IDropSource* This, BOOL fEscapePressed, DWORD grfKeyState)
{
// 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;
}
static ULONG STDMETHODCALLTYPE
idropsource_givefeedback(WB_IDropSource* This, DWORD dwEffect) {
return DRAGDROP_S_USEDEFAULTCURSORS;
}
static WB_IDropSourceVtbl ids_vtbl = {
idropsource_queryinterface,
idropsource_addref,
idropsource_release,
idropsource_querycontinuedrag,
idropsource_givefeedback
};
WB_IDropSource * WB_IDropSource_new (void) {
WB_IDropSource *result;
result = g_new0(WB_IDropSource, 1);
(WB_IDropSourceVtbl*)result->ids.lpVtbl = &ids_vtbl;
result->m_lRefCount = 1;
return result;
}
HRESULT CreateDropSource(WB_IDropSource **ppDropSource)
{
if(ppDropSource == 0)
return E_INVALIDARG;
*ppDropSource = WB_IDropSource_new();
return (*ppDropSource) ? S_OK : E_OUTOFMEMORY;
}