VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDnDDropSource.cpp@ 51287

Last change on this file since 51287 was 50177, checked in by vboxsync, 11 years ago

DnD/VBoxTray: Update.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.3 KB
Line 
1/* $Id: VBoxDnDDropSource.cpp 50177 2014-01-23 11:51:09Z vboxsync $ */
2/** @file
3 * VBoxDnDSource.cpp - IDropSource implementation.
4 */
5
6/*
7 * Copyright (C) 2013-2014 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17#include <windows.h>
18#include <new> /* For bad_alloc. */
19
20#include "VBoxTray.h"
21#include "VBoxHelpers.h"
22#include "VBoxDnD.h"
23
24#include "VBox/HostServices/DragAndDropSvc.h"
25
26
27
28VBoxDnDDropSource::VBoxDnDDropSource(VBoxDnDWnd *pParent)
29 : mRefCount(1),
30 mpWndParent(pParent),
31 mClientID(UINT32_MAX),
32 mdwCurEffect(0),
33 muCurAction(DND_IGNORE_ACTION)
34{
35 int rc = VbglR3DnDConnect(&mClientID);
36
37 LogFlowFunc(("rc=%Rrc\n", rc));
38}
39
40VBoxDnDDropSource::~VBoxDnDDropSource(void)
41{
42 int rc = VbglR3DnDDisconnect(mClientID);
43
44 LogFlowFunc(("rc=%Rrc, mRefCount=%RI32\n", rc, mRefCount));
45}
46
47/*
48 * IUnknown methods.
49 */
50
51STDMETHODIMP_(ULONG) VBoxDnDDropSource::AddRef(void)
52{
53 return InterlockedIncrement(&mRefCount);
54}
55
56STDMETHODIMP_(ULONG) VBoxDnDDropSource::Release(void)
57{
58 LONG lCount = InterlockedDecrement(&mRefCount);
59 if (lCount == 0)
60 {
61 delete this;
62 return 0;
63 }
64
65 return lCount;
66}
67
68STDMETHODIMP VBoxDnDDropSource::QueryInterface(REFIID iid, void **ppvObject)
69{
70 AssertPtrReturn(ppvObject, E_INVALIDARG);
71
72 if ( iid == IID_IDropSource
73 || iid == IID_IUnknown)
74 {
75 AddRef();
76 *ppvObject = this;
77 return S_OK;
78 }
79
80 *ppvObject = 0;
81 return E_NOINTERFACE;
82}
83
84/*
85 * IDropSource methods.
86 */
87
88/**
89 * The system informs us about whether we should continue the drag'n drop
90 * operation or not, depending on the sent key states.
91 *
92 * @return HRESULT
93 */
94STDMETHODIMP VBoxDnDDropSource::QueryContinueDrag(BOOL fEscapePressed, DWORD dwKeyState)
95{
96#ifndef DEBUG_andy
97 LogFlowFunc(("fEscapePressed=%RTbool, dwKeyState=0x%x, mdwCurEffect=%RI32, muCurAction=%RU32\n",
98 fEscapePressed, dwKeyState, mdwCurEffect, muCurAction));
99#endif
100
101 /* ESC pressed? Bail out. */
102 if (fEscapePressed)
103 {
104 mdwCurEffect = 0;
105 muCurAction = DND_IGNORE_ACTION;
106
107 return DRAGDROP_S_CANCEL;
108 }
109
110 /* Left mouse button released? Start "drop" action. */
111 if ((dwKeyState & MK_LBUTTON) == 0)
112 return DRAGDROP_S_DROP;
113
114 /* No change, just continue. */
115 return S_OK;
116}
117
118/**
119 * The drop target gives our source feedback about whether
120 * it can handle our data or not.
121 *
122 * @return HRESULT
123 */
124STDMETHODIMP VBoxDnDDropSource::GiveFeedback(DWORD dwEffect)
125{
126 uint32_t uAction = DND_IGNORE_ACTION;
127
128#ifndef DEBUG_andy
129 LogFlowFunc(("dwEffect=0x%x\n", dwEffect));
130#endif
131 if (dwEffect)
132 {
133 if (dwEffect & DROPEFFECT_COPY)
134 uAction |= DND_COPY_ACTION;
135 if (dwEffect & DROPEFFECT_MOVE)
136 uAction |= DND_MOVE_ACTION;
137 if (dwEffect & DROPEFFECT_LINK)
138 uAction |= DND_LINK_ACTION;
139 }
140
141 mdwCurEffect = dwEffect;
142 muCurAction = uAction;
143
144 return DRAGDROP_S_USEDEFAULTCURSORS;
145}
146
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette