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_DRAGDROPTREE_H__072E5B93_FD2A_11D0_ADBE_0000E81B9EF1__INCLUDED_)
19 #define AFX_DRAGDROPTREE_H__072E5B93_FD2A_11D0_ADBE_0000E81B9EF1__INCLUDED_
23 #endif // _MSC_VER >= 1000
24 // DragDropTree.h : header file
27 #include "UIImageDropTarget.h"
28 // ///////////////////////////////////////////////////////////////////////////
29 class CUI_TreeDropTarget : public CUI_ImageDropTarget
32 virtual DROPEFFECT OnDragEnter( CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point );
33 virtual DROPEFFECT OnDragOver( CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point );
34 virtual BOOL OnDrop( CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point );
35 virtual void OnDragLeave( CWnd* pWnd);
37 DWORD m_dwKeyboardState;
38 DWORD m_dwEnterKeyboardState;
41 /////////////////////////////////////////////////////////////////////////////
42 // CUIDragDropTree window
44 class CTRL_EXT_CLASS CUIDragDropTree : public CTreeCtrl
46 friend class CUI_TreeDropTarget;
49 DECLARE_DYNAMIC(CUIDragDropTree)
50 CUIDragDropTree(bool bDragDrop=true);
69 const COleDropTarget &GetDropTarget();
73 void RegisterDropTarget();
77 virtual DROPEFFECT SelectCurrentTarget(CDD_OleDropTargetInfo *pInfo);
79 // ClassWizard generated virtual function overrides
80 //{{AFX_VIRTUAL(CUIDragDropTree)
85 virtual ~CUIDragDropTree();
88 HTREEITEM GetDragItem();
89 HTREEITEM GetDropItem();
90 virtual BOOL IsChildNodeOf(HTREEITEM hitemChild, HTREEITEM hitemSuspectedParent);
91 virtual BOOL NeedToScroll( CPoint ptMouse );
92 virtual SCROLLMODE RefineScrollMode( CPoint ptMouse );
93 virtual BOOL TransferItem(HTREEITEM hitem, HTREEITEM hNewParent);
94 virtual void OnButtonUp(bool bMove);
95 virtual void OnDropFile(HTREEITEM hItem,LPCTSTR pszFile,UINT nFlags);
96 virtual void NewTransferItem(HTREEITEM hNewItem);
97 virtual BOOL StartDragDrop(NM_TREEVIEW* pNMTreeView);
98 virtual bool GetRDragMenu(CMenu *pMenu);
99 virtual void EndDragging();
100 // Generated message map functions
102 //{{AFX_MSG(CUIDragDropTree)
103 afx_msg BOOL OnBegindrag(NMHDR* pNMHDR, LRESULT* pResult);
104 afx_msg BOOL OnBeginRDrag(NMHDR* pNMHDR, LRESULT* pResult);
105 afx_msg void OnTimer(UINT nIDEvent);
106 afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
107 afx_msg void OnMouseMove(UINT nFlags, CPoint point);
108 afx_msg void OnDestroy();
109 afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
110 afx_msg void OnDropFiles( HDROP hDropInfo);
111 afx_msg void OnDDMove();
112 afx_msg void OnDDCopy();
113 afx_msg void OnDDCancel();
116 DECLARE_MESSAGE_MAP()
120 CImageList* m_pImageList;
122 HTREEITEM m_hitemDrag;
123 HTREEITEM m_hitemDrop;
125 int m_nSlowScrollTimeout;
128 int m_nScrollBarSize;
129 CUI_TreeDropTarget m_OleDropTarget;
130 COleDataSource m_OleDataSource;
134 void SetDragDrop(bool bDragDrop);
136 void SetDropFiles(bool bDropFiles);
140 inline void CUIDragDropTree::SetDragDrop(bool bDragDrop)
142 m_bDragDrop = bDragDrop;
145 inline bool CUIDragDropTree::GetDragDrop()
150 inline void CUIDragDropTree::SetDropFiles(bool bDropFiles)
152 m_bDropFiles = bDropFiles;
155 inline bool CUIDragDropTree::GetDropFiles()
160 inline const COleDropTarget &CUIDragDropTree::GetDropTarget()
162 return m_OleDropTarget;
165 inline HTREEITEM CUIDragDropTree::GetDragItem()
170 inline HTREEITEM CUIDragDropTree::GetDropItem()
175 /////////////////////////////////////////////////////////////////////////////
177 //{{AFX_INSERT_LOCATION}}
178 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
180 #endif // !defined(AFX_DRAGDROPTREE_H__072E5B93_FD2A_11D0_ADBE_0000E81B9EF1__INCLUDED_)