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 //*******************************************************************************
20 #include "UIDragDropCtrl.h"
25 static char THIS_FILE[] = __FILE__;
28 /////////////////////////////////////////////////////////////////////////////
31 CDragDropCtrl::CDragDropCtrl()
33 m_dwKeyboardState = 0;
36 CDragDropCtrl::~CDragDropCtrl()
40 void CDragDropCtrl::OnDragLeave(CWnd* pWnd)
42 CDD_OleDropTargetInfo Info(pWnd->GetSafeHwnd());
43 // was message handled?
44 if (pWnd->SendMessage(WM_APP_OLE_DD_LEAVE,(WPARAM)&Info) == FALSE)
45 pWnd->GetParent()->SendMessage(WM_APP_OLE_DD_LEAVE,(WPARAM)&Info);
46 COleDropTarget::OnDragLeave(pWnd);
49 DROPEFFECT CDragDropCtrl::OnDragEnter( CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point )
51 CDD_OleDropTargetInfo Info(pWnd->GetSafeHwnd(),point,pDataObject);
52 m_dwEnterKeyboardState = dwKeyState;
53 Info.SetKeyboardState(dwKeyState);
54 // was message handled?
55 BOOL bRet = pWnd->SendMessage(WM_APP_OLE_DD_ENTER,(WPARAM)&Info);
57 bRet = pWnd->GetParent()->SendMessage(WM_APP_OLE_DD_ENTER,(WPARAM)&Info);
58 return Info.GetDropEffect();
61 DROPEFFECT CDragDropCtrl::OnDragOver( CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point )
63 CDD_OleDropTargetInfo Info(pWnd->GetSafeHwnd(),point,pDataObject);
64 Info.SetKeyboardState(dwKeyState);
65 // was message handled?
66 m_dwKeyboardState = dwKeyState;
67 BOOL bRet = pWnd->SendMessage(WM_APP_OLE_DD_OVER,(WPARAM)&Info);
69 bRet = pWnd->GetParent()->SendMessage(WM_APP_OLE_DD_OVER,(WPARAM)&Info);
71 return DROPEFFECT_NONE;
72 return Info.GetDropEffect();
75 BOOL CDragDropCtrl::OnDrop( CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point )
77 CDD_OleDropTargetInfo Info(pWnd->GetSafeHwnd(),point,pDataObject);
78 Info.SetDropEffect(dropEffect);
79 if (m_dwEnterKeyboardState & MK_RBUTTON)
80 m_dwKeyboardState |= MK_RBUTTON;
81 if (m_dwEnterKeyboardState & MK_LBUTTON)
82 m_dwKeyboardState |= MK_LBUTTON;
83 Info.SetKeyboardState(m_dwKeyboardState);
84 BOOL bRet = pWnd->SendMessage(WM_APP_OLE_DD_DROP,(WPARAM)&Info);
85 // try parent if no reply
87 bRet = pWnd->GetParent()->SendMessage(WM_APP_OLE_DD_DROP,(WPARAM)&Info);