From b706d5658af5b834320a555c576ad08de5965cbd Mon Sep 17 00:00:00 2001 From: Jan Wilmans Date: Mon, 31 Jul 2017 22:02:12 +0200 Subject: [PATCH] working dragdrop from browser (but disabled) --- DebugView++.sln | 1 - DebugView++/DropTargetSupport.cpp | 11 ++++------- DebugView++/LogView.cpp | 7 +++---- Win32Lib/Com.cpp | 2 ++ 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/DebugView++.sln b/DebugView++.sln index 210f53bf..c17ba8fc 100644 --- a/DebugView++.sln +++ b/DebugView++.sln @@ -279,7 +279,6 @@ Global {F7F5DB6E-B52D-46C1-9E40-43934514AEEB}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU {F7F5DB6E-B52D-46C1-9E40-43934514AEEB}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU {F7F5DB6E-B52D-46C1-9E40-43934514AEEB}.Debug|Win32.ActiveCfg = Debug|Any CPU - {F7F5DB6E-B52D-46C1-9E40-43934514AEEB}.Debug|Win32.Build.0 = Debug|Any CPU {F7F5DB6E-B52D-46C1-9E40-43934514AEEB}.Debug|x64.ActiveCfg = Debug|Any CPU {F7F5DB6E-B52D-46C1-9E40-43934514AEEB}.Debug|x64.Build.0 = Debug|Any CPU {F7F5DB6E-B52D-46C1-9E40-43934514AEEB}.Debug|x86.ActiveCfg = Debug|Any CPU diff --git a/DebugView++/DropTargetSupport.cpp b/DebugView++/DropTargetSupport.cpp index 45d540a2..9e24604c 100644 --- a/DebugView++/DropTargetSupport.cpp +++ b/DebugView++/DropTargetSupport.cpp @@ -30,8 +30,6 @@ void DropTargetSupport::Unregister() 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, &m_fe, nullptr) == NO_ERROR) @@ -42,8 +40,6 @@ STDMETHODIMP DropTargetSupport::DragEnter(IDataObject* pDataObject, DWORD /*grfK break; } } - *pdwEffect = DROPEFFECT_COPY; - return S_OK; } @@ -60,13 +56,14 @@ STDMETHODIMP DropTargetSupport::DragLeave() STDMETHODIMP DropTargetSupport::Drop(IDataObject* pDataObject, DWORD /*grfKeyState*/, POINTL /*pt*/, DWORD* pdwEffect) { - auto stg = STGMEDIUM(); + auto stg = STGMEDIUM(); pDataObject->GetData(&m_fe, &stg); - auto lpData = static_cast(GlobalLock(stg.hGlobal)); + auto lpData = static_cast(GlobalLock(stg.hGlobal)); //m_view.SetWindowText(lpData); - OutputDebugString(lpData); + OutputDebugStringA(lpData); GlobalUnlock(stg.hGlobal); + ReleaseStgMedium(&stg); *pdwEffect = DROPEFFECT_COPY; return S_OK; diff --git a/DebugView++/LogView.cpp b/DebugView++/LogView.cpp index 50019b92..cec1f179 100644 --- a/DebugView++/LogView.cpp +++ b/DebugView++/LogView.cpp @@ -306,10 +306,9 @@ 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); + //CComObject::CreateInstance(&m_pDropTargetSupport); + //m_pDropTargetSupport->AddRef(); + //m_pDropTargetSupport->Register(*this); return 0; } diff --git a/Win32Lib/Com.cpp b/Win32Lib/Com.cpp index 27a7c084..f96f7742 100644 --- a/Win32Lib/Com.cpp +++ b/Win32Lib/Com.cpp @@ -17,10 +17,12 @@ ComInitialization::ComInitialization(CoInit init) HRESULT hr = CoInitializeEx(nullptr, init); //DrMemory: LEAK 264 direct bytes if (FAILED(hr)) throw Win32Error(hr, "CoInitializeEx"); + OleInitialize(nullptr); } ComInitialization::~ComInitialization() { + OleUninitialize(); CoUninitialize(); }