1 //*******************************************************************************
4 // You may use this source code, compile or redistribute it as part of your application
5 // for free. You cannot redistribute it as a part of a software development
6 // library without the agreement of the author. If the sources are
7 // distributed along with the application, you should leave the original
8 // copyright notes in the source code without any changes.
9 // This code can be used WITHOUT ANY WARRANTIES at your own risk.
11 // For the latest updates to this code, check this site:
12 // http://www.masmex.com
15 // Copyright(C) 2000 Philip Oldaker <email: philip@masmex.com>
16 //*******************************************************************************
18 #if !defined(AFX_DRAGDROPCTRL_H__BC21D3A2_332C_11D1_ADE9_0000E81B9EF1__INCLUDED_)
19 #define AFX_DRAGDROPCTRL_H__BC21D3A2_332C_11D1_ADE9_0000E81B9EF1__INCLUDED_
23 #endif // _MSC_VER >= 1000
24 // DragDropCtrl.h : header file
26 class CDD_OleDropTargetInfo : public CObject
28 DECLARE_DYNAMIC(CDD_OleDropTargetInfo)
30 CDD_OleDropTargetInfo(HWND hWnd,CPoint &point,COleDataObject *pDataObject);
31 CDD_OleDropTargetInfo(HWND hWnd);
33 void SetItem(HTREEITEM hItem);
34 void SetItem(int nItem);
35 void SetDropEffect(DROPEFFECT dropEffect);
36 void SetKeyboardState(DWORD dwKeyboardState);
38 HWND GetSafeHwnd() const;
39 CPoint GetPoint() const;
40 DWORD GetKeyboardState() const;
41 const COleDataObject *GetDataObject() const;
42 COleDataObject *GetDataObject();
43 HTREEITEM GetTreeItem() const;
44 int GetListItem() const;
45 DROPEFFECT GetDropEffect() const;
47 void InitInfo(HWND hWnd,
48 const CPoint *pPoint=NULL,
49 COleDataObject *pDataObject=NULL,
50 DROPEFFECT dropeEffect=DROPEFFECT_NONE,
55 HWND m_hWnd; // window mouse currently over
56 CPoint m_point; // mouse position in client coordinates
57 DROPEFFECT m_dropEffect; // The type of drop anticipated
58 COleDataObject *m_pDataObject; // The OLE data that was cached at startup
59 DWORD m_dwKeyState; // keyboard state when message was received
60 HTREEITEM m_hDropItem; // tree item the mouse is over or currently selected (NULL if source not a tree control)
61 int m_nDropItem; // list control item the mouse is over (-1 if source not a list control)
64 inline CDD_OleDropTargetInfo::CDD_OleDropTargetInfo(HWND hWnd,CPoint &point,COleDataObject *pDataObject)
66 InitInfo(hWnd,&point,pDataObject);
69 inline CDD_OleDropTargetInfo::CDD_OleDropTargetInfo(HWND hWnd)
74 inline void CDD_OleDropTargetInfo::InitInfo(HWND hWnd,
76 COleDataObject *pDataObject,
77 DROPEFFECT dropEffect,
87 m_pDataObject = pDataObject;
88 m_dropEffect = dropEffect;
89 m_dwKeyState = dwKeyState;
94 inline void CDD_OleDropTargetInfo::SetItem(int nItem)
99 inline void CDD_OleDropTargetInfo::SetItem(HTREEITEM hItem)
104 inline void CDD_OleDropTargetInfo::SetDropEffect(DROPEFFECT dropEffect)
106 m_dropEffect = dropEffect;
109 inline void CDD_OleDropTargetInfo::SetKeyboardState(DWORD dwKeyboardState)
111 m_dwKeyState = dwKeyboardState;
114 inline DROPEFFECT CDD_OleDropTargetInfo::GetDropEffect() const
119 inline HWND CDD_OleDropTargetInfo::GetSafeHwnd() const
124 inline CPoint CDD_OleDropTargetInfo::GetPoint() const
129 inline DWORD CDD_OleDropTargetInfo::GetKeyboardState() const
134 inline const COleDataObject *CDD_OleDropTargetInfo::GetDataObject() const
136 return m_pDataObject;
139 inline COleDataObject *CDD_OleDropTargetInfo::GetDataObject()
141 return m_pDataObject;
144 inline HTREEITEM CDD_OleDropTargetInfo::GetTreeItem() const
149 inline int CDD_OleDropTargetInfo::GetListItem() const
154 /////////////////////////////////////////////////////////////////////////////
155 // CDragDropCtrl window
157 class CTRL_EXT_CLASS CDragDropCtrl : public COleDropTarget
170 virtual DROPEFFECT OnDragEnter( CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point );
171 virtual DROPEFFECT OnDragOver( CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point );
172 virtual BOOL OnDrop( CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point );
173 virtual void OnDragLeave( CWnd* pWnd);
177 virtual ~CDragDropCtrl();
180 DWORD m_dwKeyboardState;
181 DWORD m_dwEnterKeyboardState;
184 /////////////////////////////////////////////////////////////////////////////
186 //{{AFX_INSERT_LOCATION}}
187 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
189 #endif // !defined(AFX_DRAGDROPCTRL_H__BC21D3A2_332C_11D1_ADE9_0000E81B9EF1__INCLUDED_)