-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDropTarget.h
More file actions
58 lines (45 loc) · 1.84 KB
/
Copy pathDropTarget.h
File metadata and controls
58 lines (45 loc) · 1.84 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
/** $VER: DropTarget.h (2026.07.13) P. Stuer - Implements an OLE2 drop target **/
#pragma once
#include <ole2.h>
#include <shlobj.h>
#include <shobjidl.h> // For IDropTargetHelper
#include "Resources.h"
#include "Log.h"
class playlist_uielement_t;
/// <summary>
/// Implements an OLE2 drop target.
/// </summary>
class drop_target_t : public IDropTarget
{
public:
drop_target_t(HWND hWnd, playlist_uielement_t * uiElement) noexcept : _hWnd(hWnd), _UIElement(uiElement)
{
HRESULT hr = ::CoCreateInstance(CLSID_DragDropHelper, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&_DragDropHelper));
if (!SUCCEEDED(hr))
Log.AtWarn().Write(STR_COMPONENT_BASENAME " failed to create shell drag/drop helper: 0x%08X", hr);
}
virtual ~drop_target_t() noexcept
{
if (_DragDropHelper)
{
_DragDropHelper->Release();
_DragDropHelper = nullptr;
}
}
// IUnknown
STDMETHODIMP QueryInterface(REFIID riid, void ** ppv) noexcept final;
STDMETHODIMP_(ULONG) AddRef() noexcept final;
STDMETHODIMP_(ULONG) Release() noexcept final;
// IDropTarget
STDMETHODIMP DragEnter(IDataObject * dataObject, DWORD keyState, POINTL pt, DWORD * effect) noexcept final;
STDMETHODIMP DragOver(DWORD keyState, POINTL pt, DWORD* effect) noexcept final;
STDMETHODIMP DragLeave() noexcept final;
STDMETHODIMP Drop(IDataObject * dataObject, DWORD keyState, POINTL pt, DWORD * effect) noexcept final;
private:
void ExamineDataObject(IDataObject * dataObject) const noexcept;
private:
LONG _ReferenceCount = 1;
HWND _hWnd;
playlist_uielement_t * _UIElement;
IDropTargetHelper * _DragDropHelper; // Allows drop targets to display a drag image while the image is over the target window. Exposed by the Shell's drag-image manager. It is not implemented by applications.
};