VirtualBox

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

Last change on this file since 63566 was 62679, checked in by vboxsync, 8 years ago

Use the iprt/win/windows.h wrapper for Windows.h

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
Line 
1/* $Id: VBoxDnDDropSource.cpp 62679 2016-07-29 12:52:10Z vboxsync $ */
2/** @file
3 * VBoxDnDSource.cpp - IDropSource implementation.
4 */
5
6/*
7 * Copyright (C) 2013-2016 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 <iprt/win/windows.h>
18#include <new> /* For bad_alloc. */
19
20#ifdef LOG_GROUP
21# undef LOG_GROUP
22#endif
23#define LOG_GROUP LOG_GROUP_GUEST_DND
24#include <VBox/log.h>
25
26#include "VBoxTray.h"
27#include "VBoxHelpers.h"
28#include "VBoxDnD.h"
29
30#include "VBox/HostServices/DragAndDropSvc.h"
31
32
33
34VBoxDnDDropSource::VBoxDnDDropSource(VBoxDnDWnd *pParent)
35 : mRefCount(1),
36 mpWndParent(pParent),
37 mdwCurEffect(0),
38 muCurAction(DND_IGNORE_ACTION)
39{
40 LogFlowFuncEnter();
41}
42
43VBoxDnDDropSource::~VBoxDnDDropSource(void)
44{
45 LogFlowFunc(("mRefCount=%RI32\n", mRefCount));
46}
47
48/*
49 * IUnknown methods.
50 */
51
52STDMETHODIMP_(ULONG) VBoxDnDDropSource::AddRef(void)
53{
54 return InterlockedIncrement(&mRefCount);
55}
56
57STDMETHODIMP_(ULONG) VBoxDnDDropSource::Release(void)
58{
59 LONG lCount = InterlockedDecrement(&mRefCount);
60 if (lCount == 0)
61 {
62 delete this;
63 return 0;
64 }
65
66 return lCount;
67}
68
69STDMETHODIMP VBoxDnDDropSource::QueryInterface(REFIID iid, void **ppvObject)
70{
71 AssertPtrReturn(ppvObject, E_INVALIDARG);
72
73 if ( iid == IID_IDropSource
74 || iid == IID_IUnknown)
75 {
76 AddRef();
77 *ppvObject = this;
78 return S_OK;
79 }
80
81 *ppvObject = 0;
82 return E_NOINTERFACE;
83}
84
85/*
86 * IDropSource methods.
87 */
88
89/**
90 * The system informs us about whether we should continue the drag'n drop
91 * operation or not, depending on the sent key states.
92 *
93 * @return HRESULT
94 */
95STDMETHODIMP VBoxDnDDropSource::QueryContinueDrag(BOOL fEscapePressed, DWORD dwKeyState)
96{
97#if 1
98 LogFlowFunc(("fEscapePressed=%RTbool, dwKeyState=0x%x, mdwCurEffect=%RI32, muCurAction=%RU32\n",
99 fEscapePressed, dwKeyState, mdwCurEffect, muCurAction));
100#endif
101
102 /* ESC pressed? Bail out. */
103 if (fEscapePressed)
104 {
105 mdwCurEffect = 0;
106 muCurAction = DND_IGNORE_ACTION;
107
108 LogFlowFunc(("Canceled\n"));
109 return DRAGDROP_S_CANCEL;
110 }
111
112 /* Left mouse button released? Start "drop" action. */
113 if ((dwKeyState & MK_LBUTTON) == 0)
114 {
115 LogFlowFunc(("Dropping ...\n"));
116 return DRAGDROP_S_DROP;
117 }
118
119 /* No change, just continue. */
120 return S_OK;
121}
122
123/**
124 * The drop target gives our source feedback about whether
125 * it can handle our data or not.
126 *
127 * @return HRESULT
128 */
129STDMETHODIMP VBoxDnDDropSource::GiveFeedback(DWORD dwEffect)
130{
131 uint32_t uAction = DND_IGNORE_ACTION;
132
133#if 1
134 LogFlowFunc(("dwEffect=0x%x\n", dwEffect));
135#endif
136 if (dwEffect)
137 {
138 if (dwEffect & DROPEFFECT_COPY)
139 uAction |= DND_COPY_ACTION;
140 if (dwEffect & DROPEFFECT_MOVE)
141 uAction |= DND_MOVE_ACTION;
142 if (dwEffect & DROPEFFECT_LINK)
143 uAction |= DND_LINK_ACTION;
144 }
145
146 mdwCurEffect = dwEffect;
147 muCurAction = uAction;
148
149 return DRAGDROP_S_USEDEFAULTCURSORS;
150}
151
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