0acf676b07071dfcca3c37f859008c395736563d
[reactos.git] / subsys / system / explorer / Seashell / SeaShellExt / Include / uidragdropctrl.h
1 //*******************************************************************************
2 // COPYRIGHT NOTES
3 // ---------------
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.
10 // 
11 // For the latest updates to this code, check this site:
12 // http://www.masmex.com 
13 // after Sept 2000
14 // 
15 // Copyright(C) 2000 Philip Oldaker <email: philip@masmex.com>
16 //*******************************************************************************
17
18 #if !defined(AFX_DRAGDROPCTRL_H__BC21D3A2_332C_11D1_ADE9_0000E81B9EF1__INCLUDED_)
19 #define AFX_DRAGDROPCTRL_H__BC21D3A2_332C_11D1_ADE9_0000E81B9EF1__INCLUDED_
20
21 #if _MSC_VER >= 1000
22 #pragma once
23 #endif // _MSC_VER >= 1000
24 // DragDropCtrl.h : header file
25 //
26 class CDD_OleDropTargetInfo : public CObject
27 {
28         DECLARE_DYNAMIC(CDD_OleDropTargetInfo)
29 public:
30         CDD_OleDropTargetInfo(HWND hWnd,CPoint &point,COleDataObject *pDataObject);
31         CDD_OleDropTargetInfo(HWND hWnd);
32 // Operations
33         void SetItem(HTREEITEM hItem);
34         void SetItem(int nItem);
35         void SetDropEffect(DROPEFFECT dropEffect);
36         void SetKeyboardState(DWORD dwKeyboardState);
37 // Attributes
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;
46 protected:
47         void InitInfo(HWND hWnd,
48                                         const CPoint *pPoint=NULL,
49                                         COleDataObject *pDataObject=NULL,
50                                         DROPEFFECT dropeEffect=DROPEFFECT_NONE,
51                                         DWORD dwKeyState=0,
52                                         HTREEITEM hItem=NULL,
53                                         int iItem=-1);
54 private:
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)
62 };
63
64 inline CDD_OleDropTargetInfo::CDD_OleDropTargetInfo(HWND hWnd,CPoint &point,COleDataObject *pDataObject)
65 {
66         InitInfo(hWnd,&point,pDataObject);
67 }
68
69 inline CDD_OleDropTargetInfo::CDD_OleDropTargetInfo(HWND hWnd)
70 {
71         InitInfo(hWnd);
72 }
73
74 inline void CDD_OleDropTargetInfo::InitInfo(HWND hWnd,
75                                                                                         const CPoint *pPoint,
76                                                                                         COleDataObject *pDataObject,
77                                                                                         DROPEFFECT dropEffect,
78                                                                                         DWORD dwKeyState,
79                                                                                         HTREEITEM hItem,
80                                                                                         int iItem)
81 {
82         m_hWnd = hWnd;
83         if (pPoint)
84                 m_point = *pPoint;
85         else
86                 m_point = CPoint();
87         m_pDataObject = pDataObject;
88         m_dropEffect = dropEffect;
89         m_dwKeyState = dwKeyState;
90         m_hDropItem = hItem;
91         m_nDropItem = iItem;
92 }
93
94 inline void CDD_OleDropTargetInfo::SetItem(int nItem)
95 {
96         m_nDropItem = nItem;
97 }
98
99 inline void CDD_OleDropTargetInfo::SetItem(HTREEITEM hItem)
100 {
101         m_hDropItem = hItem;
102 }
103
104 inline void CDD_OleDropTargetInfo::SetDropEffect(DROPEFFECT dropEffect)
105 {
106         m_dropEffect = dropEffect;
107 }
108
109 inline void CDD_OleDropTargetInfo::SetKeyboardState(DWORD dwKeyboardState)
110 {
111         m_dwKeyState = dwKeyboardState;
112 }
113
114 inline DROPEFFECT CDD_OleDropTargetInfo::GetDropEffect() const
115 {
116         return m_dropEffect;
117 }
118
119 inline HWND CDD_OleDropTargetInfo::GetSafeHwnd() const
120 {
121         return m_hWnd;
122 }
123
124 inline CPoint CDD_OleDropTargetInfo::GetPoint() const
125 {
126         return m_point;
127 }
128
129 inline DWORD CDD_OleDropTargetInfo::GetKeyboardState() const
130 {
131         return m_dwKeyState;
132 }
133
134 inline const COleDataObject *CDD_OleDropTargetInfo::GetDataObject() const
135 {
136         return m_pDataObject;
137 }
138
139 inline COleDataObject *CDD_OleDropTargetInfo::GetDataObject()
140 {
141         return m_pDataObject;
142 }
143
144 inline HTREEITEM CDD_OleDropTargetInfo::GetTreeItem() const
145 {
146         return m_hDropItem;
147 }
148
149 inline int CDD_OleDropTargetInfo::GetListItem() const
150 {
151         return m_nDropItem;
152 }
153
154 /////////////////////////////////////////////////////////////////////////////
155 // CDragDropCtrl window
156
157 class CTRL_EXT_CLASS CDragDropCtrl : public COleDropTarget
158 {
159 // Construction
160 public:
161         CDragDropCtrl();
162
163 // Attributes
164 public:
165
166 // Operations
167 public:
168
169 // Overrides
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);
174
175 // Implementation
176 public:
177         virtual ~CDragDropCtrl();
178
179 private:
180         DWORD m_dwKeyboardState;
181         DWORD m_dwEnterKeyboardState;
182 };
183
184 /////////////////////////////////////////////////////////////////////////////
185
186 //{{AFX_INSERT_LOCATION}}
187 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
188
189 #endif // !defined(AFX_DRAGDROPCTRL_H__BC21D3A2_332C_11D1_ADE9_0000E81B9EF1__INCLUDED_)