From 3970db8eb8a97b11ba42c97d62a185d76001f6b0 Mon Sep 17 00:00:00 2001 From: Jan Wilmans Date: Mon, 31 Jul 2017 21:28:53 +0200 Subject: [PATCH] move DropTargetSupport to logview (no effect so far) --- DebugView++/DropTargetSupport.cpp | 17 +++++++++++++---- DebugView++/DropTargetSupport.h | 16 +++++++++++----- DebugView++/LogView.cpp | 5 +++++ DebugView++/LogView.h | 2 ++ DebugView++/MainFrame.cpp | 5 ----- DebugView++/MainFrame.h | 5 +---- 6 files changed, 32 insertions(+), 18 deletions(-) diff --git a/DebugView++/DropTargetSupport.cpp b/DebugView++/DropTargetSupport.cpp index 67132c45..45d540a2 100644 --- a/DebugView++/DropTargetSupport.cpp +++ b/DebugView++/DropTargetSupport.cpp @@ -11,6 +11,12 @@ namespace fusion { namespace debugviewpp { +DropTargetSupport::DropTargetSupport() + : m_fe({0}) + , m_hwnd(nullptr) +{ +} + void DropTargetSupport::Register(HWND hwnd) { m_hwnd = hwnd; @@ -22,19 +28,22 @@ void DropTargetSupport::Unregister() RevokeDragDrop(m_hwnd); } -FORMATETC fe = {0}; STDMETHODIMP DropTargetSupport::DragEnter(IDataObject* pDataObject, DWORD /*grfKeyState*/, POINTL /*pt*/, DWORD* pdwEffect) { + + *pdwEffect = DROPEFFECT_SCROLL; CComPtr pEnum; pDataObject->EnumFormatEtc(DATADIR_GET, &pEnum); - while (pEnum->Next(1, &fe, nullptr) == NO_ERROR) + while (pEnum->Next(1, &m_fe, nullptr) == NO_ERROR) { - if (fe.cfFormat == CF_TEXT) + if (m_fe.cfFormat == CF_TEXT) { *pdwEffect = DROPEFFECT_COPY; break; } } + *pdwEffect = DROPEFFECT_COPY; + return S_OK; } @@ -52,7 +61,7 @@ STDMETHODIMP DropTargetSupport::DragLeave() STDMETHODIMP DropTargetSupport::Drop(IDataObject* pDataObject, DWORD /*grfKeyState*/, POINTL /*pt*/, DWORD* pdwEffect) { auto stg = STGMEDIUM(); - pDataObject->GetData(&fe, &stg); + pDataObject->GetData(&m_fe, &stg); auto lpData = static_cast(GlobalLock(stg.hGlobal)); //m_view.SetWindowText(lpData); diff --git a/DebugView++/DropTargetSupport.h b/DebugView++/DropTargetSupport.h index 7723facb..2c481d62 100644 --- a/DebugView++/DropTargetSupport.h +++ b/DebugView++/DropTargetSupport.h @@ -12,23 +12,29 @@ namespace fusion { namespace debugviewpp { -class DropTargetSupport : public CComObjectRootEx, public IDropTarget +class ATL_NO_VTABLE DropTargetSupport : public CComObjectRootEx, public IDropTarget { public: BEGIN_COM_MAP(DropTargetSupport) COM_INTERFACE_ENTRY(IDropTarget) END_COM_MAP() + DropTargetSupport(); + void Register(HWND hwnd); + void Unregister(); + + // HRESULT QueryInterface(REFIID riid, void **ppvObject) + //{ + // CComObjectRootBase::QueryInterface(riid, ppvObject); + //} + STDMETHOD(DragEnter)(IDataObject* pDataObject, DWORD grfKeyState, POINTL pt, DWORD* pdwEffect); STDMETHOD(DragOver)(DWORD grfKeyState, POINTL pt, DWORD* pdwEffect); STDMETHOD(DragLeave)(); STDMETHOD(Drop)(IDataObject* pDataObject, DWORD grfKeyState, POINTL pt, DWORD* pdwEffect); - DropTargetSupport() = default; - void Register(HWND hwnd); - void Unregister(); - private: + FORMATETC m_fe; HWND m_hwnd; }; diff --git a/DebugView++/LogView.cpp b/DebugView++/LogView.cpp index 306432b5..50019b92 100644 --- a/DebugView++/LogView.cpp +++ b/DebugView++/LogView.cpp @@ -306,6 +306,11 @@ LRESULT CLogView::OnCreate(const CREATESTRUCT* /*pCreate*/) ApplyFilters(); + // todo: find out why DropTargetSupport::DragEnter is never called... + CComObject::CreateInstance(&m_pDropTargetSupport); + m_pDropTargetSupport->AddRef(); + m_pDropTargetSupport->Register(*this); + return 0; } diff --git a/DebugView++/LogView.h b/DebugView++/LogView.h index a2f7b1e0..7a2a2d3e 100644 --- a/DebugView++/LogView.h +++ b/DebugView++/LogView.h @@ -14,6 +14,7 @@ #include "CobaltFusion/AtlWinExt.h" #include "DebugView++Lib/LogFile.h" #include "FilterDlg.h" +#include "DropTargetSupport.h" namespace fusion { namespace debugviewpp { @@ -297,6 +298,7 @@ class CLogView : bool m_dragging; int m_scrollX; std::wstring m_dispInfoText; + CComObject * m_pDropTargetSupport; }; } // namespace debugviewpp diff --git a/DebugView++/MainFrame.cpp b/DebugView++/MainFrame.cpp index 9c9e3006..4344d8de 100644 --- a/DebugView++/MainFrame.cpp +++ b/DebugView++/MainFrame.cpp @@ -199,11 +199,6 @@ LRESULT CMainFrame::OnCreate(const CREATESTRUCT* /*pCreate*/) { m_notifyIconData.cbSize = 0; - // todo: find out why DropTargetSupport::DragEnter is never called... - //CComObject::CreateInstance(&m_pDropTargetSupport); - //m_pDropTargetSupport->AddRef(); - //m_pDropTargetSupport->Register(*this); - HWND hWndCmdBar = m_cmdBar.Create(*this, rcDefault, nullptr, ATL_SIMPLE_CMDBAR_PANE_STYLE); m_cmdBar.AttachMenu(GetMenu()); m_cmdBar.LoadImages(IDR_MAINFRAME); diff --git a/DebugView++/MainFrame.h b/DebugView++/MainFrame.h index eea05d4a..691c20e5 100644 --- a/DebugView++/MainFrame.h +++ b/DebugView++/MainFrame.h @@ -16,7 +16,6 @@ using ATL::CString; }; #include -#include "DropTargetSupport.h" #pragma warning(push, 3) #pragma warning(disable : 4838) @@ -87,7 +86,7 @@ class CMainFrame : public CTabbedFrameImpl> TabbedFrame; CMainFrame(); - ~CMainFrame(); + ~CMainFrame(); DECLARE_FRAME_WND_CLASS(nullptr, IDR_MAINFRAME) @@ -119,7 +118,6 @@ class CMainFrame : public CTabbedFrameImpl m_sourceInfos; std::unique_ptr m_GuiExecutorClient; LogSources m_logSources; - CComObject * m_pDropTargetSupport; }; } // namespace debugviewpp