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

图形图象

开发平台:

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. #include "stdafx.h"
  18. #include "UICtrl.h"
  19. #include "UIDragImage.h"
  20. #include "UIDropTarget.h"
  21. #include "UIDragDropCtrl.h"
  22. #ifdef _DEBUG
  23. #define new DEBUG_NEW
  24. #undef THIS_FILE
  25. static char THIS_FILE[] = __FILE__;
  26. #endif
  27. IMPLEMENT_DYNAMIC(CDD_OleDropTargetInfo,CObject)
  28. void CListDropTarget::OnDragLeave(CWnd* pWnd)
  29. {
  30. CUI_ImageDropTarget::OnDragLeave(pWnd);
  31. CDD_OleDropTargetInfo Info(pWnd->GetSafeHwnd());
  32. if (!pWnd->SendMessage(WM_APP_OLE_DD_LEAVE,(WPARAM)&Info))
  33. pWnd->GetParent()->SendMessage(WM_APP_OLE_DD_LEAVE,(WPARAM)&Info);
  34. }
  35. DROPEFFECT CListDropTarget::OnDragEnter( CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point )
  36. {
  37. // Should be starting in a CUIODListCtrl window
  38. CUI_ImageDropTarget::OnDragEnter(pWnd,pDataObject,dwKeyState,point);
  39. CDD_OleDropTargetInfo Info(pWnd->GetSafeHwnd(),point,pDataObject);
  40. Info.SetKeyboardState(dwKeyState);
  41. if (!pWnd->SendMessage(WM_APP_OLE_DD_ENTER,(WPARAM)&Info))
  42. pWnd->GetParent()->SendMessage(WM_APP_OLE_DD_ENTER,(WPARAM)&Info);
  43. return Info.GetDropEffect();
  44. }
  45. DROPEFFECT CListDropTarget::OnDragOver( CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point )
  46. {
  47. // check if any image to draw
  48. if (GetDropImage() != NULL)
  49. CUI_ImageDropTarget::OnDragOver(pWnd,pDataObject,dwKeyState,point);
  50. m_dwKeyboardState = dwKeyState;
  51. CDD_OleDropTargetInfo Info(pWnd->GetSafeHwnd(),point,pDataObject);
  52. Info.SetKeyboardState(dwKeyState);
  53. // this will fill in info with item if mouse over one
  54. CUIODListCtrl *pList = static_cast<CUIODListCtrl*>(pWnd);
  55. return pList ? pList->SelectCurrentTarget(&Info) : DROPEFFECT_NONE;
  56. }
  57. BOOL CListDropTarget::OnDrop( CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point )
  58. {
  59. CUI_ImageDropTarget::OnDrop(pWnd,pDataObject,dropEffect,point);
  60. TRACE0("CListDropTraget - OnDropn");
  61. // should be list control
  62. CUIODListCtrl *pList = static_cast<CUIODListCtrl*>(pWnd);
  63. if (pList != NULL)
  64. {
  65. UINT flags;
  66. int iItem = pList->HitTest(point, &flags);
  67. CDD_OleDropTargetInfo Info(pWnd->GetSafeHwnd(),point,pDataObject);
  68. Info.SetDropEffect(dropEffect);
  69. Info.SetItem(iItem);
  70. Info.SetKeyboardState(m_dwKeyboardState);
  71. // alert control first otherwise parent
  72. if (!pWnd->SendMessage(WM_APP_OLE_DD_DROP,(WPARAM)&Info))
  73. return pWnd->GetParent()->SendMessage(WM_APP_OLE_DD_DROP,(WPARAM)&Info);
  74. }
  75. return CUI_ImageDropTarget::OnDrop(pWnd,pDataObject,dropEffect,point);
  76. }