mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-23 21:01:01 +08:00
98 lines
3.0 KiB
C++
98 lines
3.0 KiB
C++
// encoding: UTF-8
|
|
/******************************************************************************
|
|
* *
|
|
* *
|
|
* MiniPath - Notepad3 Explorer Plugin *
|
|
* *
|
|
* Dropsource.cpp *
|
|
* OLE drop source functionality *
|
|
* Based on code from metapath, (c) Florian Balmer 1996-2011 *
|
|
* *
|
|
* (c) Rizonesoft 2008-2026 *
|
|
* https://rizonesoft.com *
|
|
* *
|
|
* *
|
|
*******************************************************************************/
|
|
#include <sdkddkver.h>
|
|
#ifndef _WIN32_WINNT
|
|
#define _WIN32_WINNT _WIN32_WINNT_WIN10
|
|
#endif
|
|
#define WIN32_LEAN_AND_MEAN 1
|
|
#include <windows.h>
|
|
#include <ole2.h>
|
|
//#include <strsafe.h>
|
|
#include "DropSource.h"
|
|
|
|
/******************************************************************************
|
|
*
|
|
* IUnknown Implementation
|
|
*
|
|
******************************************************************************/
|
|
STDMETHODIMP CDropSource::QueryInterface(REFIID iid, PVOID *ppv) noexcept
|
|
{
|
|
if (iid == IID_IUnknown || iid == IID_IDropSource) {
|
|
*ppv = this;
|
|
AddRef();
|
|
return NOERROR;
|
|
}
|
|
*ppv = nullptr;
|
|
return E_NOINTERFACE;
|
|
}
|
|
|
|
STDMETHODIMP_(ULONG) CDropSource::AddRef() noexcept
|
|
{
|
|
return ++m_refs;
|
|
}
|
|
|
|
STDMETHODIMP_(ULONG) CDropSource::Release() noexcept
|
|
{
|
|
const ULONG refs = --m_refs;
|
|
if (refs == 0) {
|
|
delete this;
|
|
}
|
|
return refs;
|
|
}
|
|
|
|
/******************************************************************************
|
|
*
|
|
* CDropSource Constructor
|
|
*
|
|
******************************************************************************/
|
|
CDropSource::CDropSource() noexcept
|
|
{
|
|
m_refs = 1;
|
|
}
|
|
|
|
/******************************************************************************
|
|
*
|
|
* IDropSource Implementation
|
|
*
|
|
******************************************************************************/
|
|
STDMETHODIMP CDropSource::QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState) noexcept
|
|
{
|
|
if (fEscapePressed) {
|
|
return DRAGDROP_S_CANCEL;
|
|
}
|
|
if (!(grfKeyState & MK_LBUTTON) && !(grfKeyState & MK_RBUTTON)) {
|
|
return DRAGDROP_S_DROP;
|
|
}
|
|
return NOERROR;
|
|
}
|
|
|
|
STDMETHODIMP CDropSource::GiveFeedback(DWORD dwEffect) noexcept
|
|
{
|
|
(void)(dwEffect);
|
|
return DRAGDROP_S_USEDEFAULTCURSORS;
|
|
}
|
|
|
|
extern "C" {
|
|
|
|
LPDROPSOURCE CreateDropSource(void)
|
|
{
|
|
return ((LPDROPSOURCE) new CDropSource);
|
|
}
|
|
|
|
}
|
|
|
|
// End of DropSource.cpp
|