uidragdropctrl.h
上传用户:yatsl7111
上传日期:2007-01-08
资源大小:1433k
文件大小:5k
源码类别:

图形图象

开发平台:

Visual C++

  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. #if !defined(AFX_DRAGDROPCTRL_H__BC21D3A2_332C_11D1_ADE9_0000E81B9EF1__INCLUDED_)
  18. #define AFX_DRAGDROPCTRL_H__BC21D3A2_332C_11D1_ADE9_0000E81B9EF1__INCLUDED_
  19. #if _MSC_VER >= 1000
  20. #pragma once
  21. #endif // _MSC_VER >= 1000
  22. // DragDropCtrl.h : header file
  23. //
  24. class CDD_OleDropTargetInfo : public CObject
  25. {
  26. DECLARE_DYNAMIC(CDD_OleDropTargetInfo)
  27. public:
  28. CDD_OleDropTargetInfo(HWND hWnd,CPoint &point,COleDataObject *pDataObject);
  29. CDD_OleDropTargetInfo(HWND hWnd);
  30. // Operations
  31. void SetItem(HTREEITEM hItem);
  32. void SetItem(int nItem);
  33. void SetDropEffect(DROPEFFECT dropEffect);
  34. void SetKeyboardState(DWORD dwKeyboardState);
  35. // Attributes
  36. HWND GetSafeHwnd() const;
  37. CPoint GetPoint() const;
  38. DWORD GetKeyboardState() const;
  39. const COleDataObject *GetDataObject() const;
  40. COleDataObject *GetDataObject();
  41. HTREEITEM GetTreeItem() const;
  42. int GetListItem() const;
  43. DROPEFFECT GetDropEffect() const;
  44. protected:
  45. void InitInfo(HWND hWnd,
  46. const CPoint *pPoint=NULL,
  47. COleDataObject *pDataObject=NULL,
  48. DROPEFFECT dropeEffect=DROPEFFECT_NONE,
  49. DWORD dwKeyState=0,
  50. HTREEITEM hItem=NULL,
  51. int iItem=-1);
  52. private:
  53. HWND m_hWnd; // window mouse currently over
  54. CPoint m_point; // mouse position in client coordinates
  55. DROPEFFECT m_dropEffect; // The type of drop anticipated
  56. COleDataObject *m_pDataObject; // The OLE data that was cached at startup
  57. DWORD m_dwKeyState; // keyboard state when message was received
  58. HTREEITEM m_hDropItem; // tree item the mouse is over or currently selected (NULL if source not a tree control)
  59. int m_nDropItem; // list control item the mouse is over (-1 if source not a list control)
  60. };
  61. inline CDD_OleDropTargetInfo::CDD_OleDropTargetInfo(HWND hWnd,CPoint &point,COleDataObject *pDataObject)
  62. {
  63. InitInfo(hWnd,&point,pDataObject);
  64. }
  65. inline CDD_OleDropTargetInfo::CDD_OleDropTargetInfo(HWND hWnd)
  66. {
  67. InitInfo(hWnd);
  68. }
  69. inline void CDD_OleDropTargetInfo::InitInfo(HWND hWnd,
  70. const CPoint *pPoint,
  71. COleDataObject *pDataObject,
  72. DROPEFFECT dropEffect,
  73. DWORD dwKeyState,
  74. HTREEITEM hItem,
  75. int iItem)
  76. {
  77. m_hWnd = hWnd;
  78. if (pPoint)
  79. m_point = *pPoint;
  80. else
  81. m_point = CPoint();
  82. m_pDataObject = pDataObject;
  83. m_dropEffect = dropEffect;
  84. m_dwKeyState = dwKeyState;
  85. m_hDropItem = hItem;
  86. m_nDropItem = iItem;
  87. }
  88. inline void CDD_OleDropTargetInfo::SetItem(int nItem)
  89. {
  90. m_nDropItem = nItem;
  91. }
  92. inline void CDD_OleDropTargetInfo::SetItem(HTREEITEM hItem)
  93. {
  94. m_hDropItem = hItem;
  95. }
  96. inline void CDD_OleDropTargetInfo::SetDropEffect(DROPEFFECT dropEffect)
  97. {
  98. m_dropEffect = dropEffect;
  99. }
  100. inline void CDD_OleDropTargetInfo::SetKeyboardState(DWORD dwKeyboardState)
  101. {
  102. m_dwKeyState = dwKeyboardState;
  103. }
  104. inline DROPEFFECT CDD_OleDropTargetInfo::GetDropEffect() const
  105. {
  106. return m_dropEffect;
  107. }
  108. inline HWND CDD_OleDropTargetInfo::GetSafeHwnd() const
  109. {
  110. return m_hWnd;
  111. }
  112. inline CPoint CDD_OleDropTargetInfo::GetPoint() const
  113. {
  114. return m_point;
  115. }
  116. inline DWORD CDD_OleDropTargetInfo::GetKeyboardState() const
  117. {
  118. return m_dwKeyState;
  119. }
  120. inline const COleDataObject *CDD_OleDropTargetInfo::GetDataObject() const
  121. {
  122. return m_pDataObject;
  123. }
  124. inline COleDataObject *CDD_OleDropTargetInfo::GetDataObject()
  125. {
  126. return m_pDataObject;
  127. }
  128. inline HTREEITEM CDD_OleDropTargetInfo::GetTreeItem() const
  129. {
  130. return m_hDropItem;
  131. }
  132. inline int CDD_OleDropTargetInfo::GetListItem() const
  133. {
  134. return m_nDropItem;
  135. }
  136. /////////////////////////////////////////////////////////////////////////////
  137. // CDragDropCtrl window
  138. class CTRL_EXT_CLASS CDragDropCtrl : public COleDropTarget
  139. {
  140. // Construction
  141. public:
  142. CDragDropCtrl();
  143. // Attributes
  144. public:
  145. // Operations
  146. public:
  147. // Overrides
  148. virtual DROPEFFECT OnDragEnter( CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point );
  149. virtual DROPEFFECT OnDragOver( CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point );
  150. virtual BOOL OnDrop( CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point );
  151. virtual void OnDragLeave( CWnd* pWnd);
  152. // Implementation
  153. public:
  154. virtual ~CDragDropCtrl();
  155. private:
  156. DWORD m_dwKeyboardState;
  157. DWORD m_dwEnterKeyboardState;
  158. };
  159. /////////////////////////////////////////////////////////////////////////////
  160. //{{AFX_INSERT_LOCATION}}
  161. // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
  162. #endif // !defined(AFX_DRAGDROPCTRL_H__BC21D3A2_332C_11D1_ADE9_0000E81B9EF1__INCLUDED_)