Skip to content

Commit

Permalink
move DropTargetSupport to logview (no effect so far)
Browse files Browse the repository at this point in the history
  • Loading branch information
janwilmans committed Jul 31, 2017
1 parent 45f67b9 commit 3970db8
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 18 deletions.
17 changes: 13 additions & 4 deletions DebugView++/DropTargetSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
namespace fusion {
namespace debugviewpp {

DropTargetSupport::DropTargetSupport()
: m_fe({0})
, m_hwnd(nullptr)
{
}

void DropTargetSupport::Register(HWND hwnd)
{
m_hwnd = hwnd;
Expand All @@ -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<IEnumFORMATETC> 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;
}

Expand All @@ -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<LPCTSTR>(GlobalLock(stg.hGlobal));

//m_view.SetWindowText(lpData);
Expand Down
16 changes: 11 additions & 5 deletions DebugView++/DropTargetSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,29 @@
namespace fusion {
namespace debugviewpp {

class DropTargetSupport : public CComObjectRootEx<CComSingleThreadModel>, public IDropTarget
class ATL_NO_VTABLE DropTargetSupport : public CComObjectRootEx<CComSingleThreadModel>, 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;
};

Expand Down
5 changes: 5 additions & 0 deletions DebugView++/LogView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,11 @@ LRESULT CLogView::OnCreate(const CREATESTRUCT* /*pCreate*/)

ApplyFilters();

// todo: find out why DropTargetSupport::DragEnter is never called...
CComObject<DropTargetSupport>::CreateInstance(&m_pDropTargetSupport);
m_pDropTargetSupport->AddRef();
m_pDropTargetSupport->Register(*this);

return 0;
}

Expand Down
2 changes: 2 additions & 0 deletions DebugView++/LogView.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "CobaltFusion/AtlWinExt.h"
#include "DebugView++Lib/LogFile.h"
#include "FilterDlg.h"
#include "DropTargetSupport.h"

namespace fusion {
namespace debugviewpp {
Expand Down Expand Up @@ -297,6 +298,7 @@ class CLogView :
bool m_dragging;
int m_scrollX;
std::wstring m_dispInfoText;
CComObject<DropTargetSupport> * m_pDropTargetSupport;
};

} // namespace debugviewpp
Expand Down
5 changes: 0 additions & 5 deletions DebugView++/MainFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,6 @@ LRESULT CMainFrame::OnCreate(const CREATESTRUCT* /*pCreate*/)
{
m_notifyIconData.cbSize = 0;

// todo: find out why DropTargetSupport::DragEnter is never called...
//CComObject<DropTargetSupport>::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);
Expand Down
5 changes: 1 addition & 4 deletions DebugView++/MainFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ using ATL::CString;
};

#include <atlcom.h>
#include "DropTargetSupport.h"

#pragma warning(push, 3)
#pragma warning(disable : 4838)
Expand Down Expand Up @@ -87,7 +86,7 @@ class CMainFrame : public CTabbedFrameImpl<CMainFrame, CDotNetTabCtrl<SelectedTa
typedef CTabbedFrameImpl<CMainFrame, CDotNetTabCtrl<SelectedTabItem>> TabbedFrame;

CMainFrame();
~CMainFrame();
~CMainFrame();

DECLARE_FRAME_WND_CLASS(nullptr, IDR_MAINFRAME)

Expand Down Expand Up @@ -119,7 +118,6 @@ class CMainFrame : public CTabbedFrameImpl<CMainFrame, CDotNetTabCtrl<SelectedTa
void LoadConfiguration(const std::wstring& fileName);
void SaveConfiguration(const std::wstring& fileName);
void Load(const std::wstring& fileName, bool keeptailing);
void LoadAsync(const std::wstring& fileName);
void Load(HANDLE hFile);
void Load(std::istream& is, const std::string& name, FILETIME fileTime);
void CapturePipe(HANDLE hPipe);
Expand Down Expand Up @@ -246,7 +244,6 @@ class CMainFrame : public CTabbedFrameImpl<CMainFrame, CDotNetTabCtrl<SelectedTa
std::vector<SourceInfo> m_sourceInfos;
std::unique_ptr<GuiExecutorClient> m_GuiExecutorClient;
LogSources m_logSources;
CComObject<DropTargetSupport> * m_pDropTargetSupport;
};

} // namespace debugviewpp
Expand Down

0 comments on commit 3970db8

Please sign in to comment.