This repository has been archived by the owner on Feb 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
GridDropTarget.cpp
executable file
·128 lines (104 loc) · 3.54 KB
/
GridDropTarget.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// GridDropTarget.cpp : implementation file
//
// CGridDropTarget is an OLE drop target for CGridCtrl. All it does
// is handle the drag and drop windows messages and pass them
// directly onto the grid control.
//
// Written by Chris Maunder
// mailto:[email protected]
//
// Copyright (c) 1998.
#include "stdafx.h"
#include "GridCtrl.h"
#ifndef GRIDCONTROL_NO_DRAGDROP
#include "GridDropTarget.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CGridDropTarget
CGridDropTarget::CGridDropTarget()
{
m_pGridCtrl = NULL;
m_bRegistered = FALSE;
}
CGridDropTarget::~CGridDropTarget()
{
}
// Overloaded Register() function performs the normal COleDropTarget::Register
// but also serves to connect this COleDropTarget with the parent grid control,
// where all drop messages will ultimately be forwarded.
BOOL CGridDropTarget::Register(CGridCtrl *pGridCtrl)
{
if (m_bRegistered) return FALSE;
ASSERT(pGridCtrl->IsKindOf(RUNTIME_CLASS(CGridCtrl)));
ASSERT(pGridCtrl);
if (!pGridCtrl || !pGridCtrl->IsKindOf(RUNTIME_CLASS(CGridCtrl)))
return FALSE;
m_pGridCtrl = pGridCtrl;
m_bRegistered = COleDropTarget::Register(pGridCtrl);
return m_bRegistered;
}
void CGridDropTarget::Revoke()
{
m_bRegistered = FALSE;
COleDropTarget::Revoke();
}
BEGIN_MESSAGE_MAP(CGridDropTarget, COleDropTarget)
//{{AFX_MSG_MAP(CGridDropTarget)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CGridDropTarget message handlers
DROPEFFECT CGridDropTarget::OnDragScroll(CWnd* pWnd, DWORD dwKeyState, CPoint /*point*/)
{
// TRACE("In CGridDropTarget::OnDragScroll\n");
if (pWnd->GetSafeHwnd() == m_pGridCtrl->GetSafeHwnd())
{
if (dwKeyState & MK_CONTROL)
return DROPEFFECT_COPY;
else
return DROPEFFECT_MOVE;
} else
return DROPEFFECT_NONE;
}
DROPEFFECT CGridDropTarget::OnDragEnter(CWnd* pWnd, COleDataObject* pDataObject,
DWORD dwKeyState, CPoint point)
{
TRACE(_T("In CGridDropTarget::OnDragEnter\n"));
ASSERT(m_pGridCtrl);
if (pWnd->GetSafeHwnd() == m_pGridCtrl->GetSafeHwnd())
return m_pGridCtrl->OnDragEnter(pDataObject, dwKeyState, point);
else
return DROPEFFECT_NONE;
}
void CGridDropTarget::OnDragLeave(CWnd* pWnd)
{
TRACE(_T("In CGridDropTarget::OnDragLeave\n"));
ASSERT(m_pGridCtrl);
if (pWnd->GetSafeHwnd() == m_pGridCtrl->GetSafeHwnd())
m_pGridCtrl->OnDragLeave();
}
DROPEFFECT CGridDropTarget::OnDragOver(CWnd* pWnd, COleDataObject* pDataObject,
DWORD dwKeyState, CPoint point)
{
// TRACE("In CGridDropTarget::OnDragOver\n");
ASSERT(m_pGridCtrl);
if (pWnd->GetSafeHwnd() == m_pGridCtrl->GetSafeHwnd())
return m_pGridCtrl->OnDragOver(pDataObject, dwKeyState, point);
else
return DROPEFFECT_NONE;
}
BOOL CGridDropTarget::OnDrop(CWnd* pWnd, COleDataObject* pDataObject,
DROPEFFECT dropEffect, CPoint point)
{
TRACE(_T("In CGridDropTarget::OnDrop\n"));
ASSERT(m_pGridCtrl);
if (pWnd->GetSafeHwnd() == m_pGridCtrl->GetSafeHwnd())
return m_pGridCtrl->OnDrop(pDataObject, dropEffect, point);
else
return FALSE;
}
#endif // GRIDCONTROL_NO_DRAGDROP