uidragdropctrl.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 "UIDragDropCtrl.h"
  20. #ifdef _DEBUG
  21. #define new DEBUG_NEW
  22. #undef THIS_FILE
  23. static char THIS_FILE[] = __FILE__;
  24. #endif
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CDragDropCtrl
  27. CDragDropCtrl::CDragDropCtrl()
  28. {
  29. m_dwKeyboardState = 0;
  30. }
  31. CDragDropCtrl::~CDragDropCtrl()
  32. {
  33. }
  34. void CDragDropCtrl::OnDragLeave(CWnd* pWnd)
  35. {
  36. CDD_OleDropTargetInfo Info(pWnd->GetSafeHwnd());
  37. // was message handled?
  38. if (pWnd->SendMessage(WM_APP_OLE_DD_LEAVE,(WPARAM)&Info) == FALSE)
  39. pWnd->GetParent()->SendMessage(WM_APP_OLE_DD_LEAVE,(WPARAM)&Info);
  40. COleDropTarget::OnDragLeave(pWnd);
  41. }
  42. DROPEFFECT CDragDropCtrl::OnDragEnter( CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point )
  43. {
  44. CDD_OleDropTargetInfo Info(pWnd->GetSafeHwnd(),point,pDataObject);
  45. m_dwEnterKeyboardState = dwKeyState;
  46. Info.SetKeyboardState(dwKeyState);
  47. // was message handled?
  48. BOOL bRet = pWnd->SendMessage(WM_APP_OLE_DD_ENTER,(WPARAM)&Info);
  49. if (bRet == FALSE)
  50. bRet = pWnd->GetParent()->SendMessage(WM_APP_OLE_DD_ENTER,(WPARAM)&Info);
  51. return Info.GetDropEffect();
  52. }
  53. DROPEFFECT CDragDropCtrl::OnDragOver( CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point )
  54. {
  55. CDD_OleDropTargetInfo Info(pWnd->GetSafeHwnd(),point,pDataObject);
  56. Info.SetKeyboardState(dwKeyState);
  57. // was message handled?
  58. m_dwKeyboardState = dwKeyState;
  59. BOOL bRet = pWnd->SendMessage(WM_APP_OLE_DD_OVER,(WPARAM)&Info);
  60. if (bRet == FALSE)
  61. bRet = pWnd->GetParent()->SendMessage(WM_APP_OLE_DD_OVER,(WPARAM)&Info);
  62. if (bRet == FALSE)
  63. return DROPEFFECT_NONE;
  64. return Info.GetDropEffect();
  65. }
  66. BOOL CDragDropCtrl::OnDrop( CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point )
  67. {
  68. CDD_OleDropTargetInfo Info(pWnd->GetSafeHwnd(),point,pDataObject);
  69. Info.SetDropEffect(dropEffect);
  70. if (m_dwEnterKeyboardState & MK_RBUTTON)
  71. m_dwKeyboardState |= MK_RBUTTON;
  72. if (m_dwEnterKeyboardState & MK_LBUTTON)
  73. m_dwKeyboardState |= MK_LBUTTON;
  74. Info.SetKeyboardState(m_dwKeyboardState);
  75. BOOL bRet = pWnd->SendMessage(WM_APP_OLE_DD_DROP,(WPARAM)&Info);
  76. // try parent if no reply
  77. if (bRet == FALSE) 
  78. bRet = pWnd->GetParent()->SendMessage(WM_APP_OLE_DD_DROP,(WPARAM)&Info);
  79. return bRet;
  80. }