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 "UIDragImage.h"
21 #include "UIDropTarget.h"
22 #include "UIDragDropCtrl.h"
27 static char THIS_FILE[] = __FILE__;
30 IMPLEMENT_DYNAMIC(CDD_OleDropTargetInfo,CObject)
32 void CListDropTarget::OnDragLeave(CWnd* pWnd)
34 CUI_ImageDropTarget::OnDragLeave(pWnd);
35 CDD_OleDropTargetInfo Info(pWnd->GetSafeHwnd());
36 if (!pWnd->SendMessage(WM_APP_OLE_DD_LEAVE,(WPARAM)&Info))
37 pWnd->GetParent()->SendMessage(WM_APP_OLE_DD_LEAVE,(WPARAM)&Info);
40 DROPEFFECT CListDropTarget::OnDragEnter( CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point )
42 // Should be starting in a CUIODListCtrl window
43 CUI_ImageDropTarget::OnDragEnter(pWnd,pDataObject,dwKeyState,point);
44 CDD_OleDropTargetInfo Info(pWnd->GetSafeHwnd(),point,pDataObject);
45 Info.SetKeyboardState(dwKeyState);
46 if (!pWnd->SendMessage(WM_APP_OLE_DD_ENTER,(WPARAM)&Info))
47 pWnd->GetParent()->SendMessage(WM_APP_OLE_DD_ENTER,(WPARAM)&Info);
48 return Info.GetDropEffect();
51 DROPEFFECT CListDropTarget::OnDragOver( CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point )
53 // check if any image to draw
54 if (GetDropImage() != NULL)
55 CUI_ImageDropTarget::OnDragOver(pWnd,pDataObject,dwKeyState,point);
56 m_dwKeyboardState = dwKeyState;
57 CDD_OleDropTargetInfo Info(pWnd->GetSafeHwnd(),point,pDataObject);
58 Info.SetKeyboardState(dwKeyState);
59 // this will fill in info with item if mouse over one
60 CUIODListCtrl *pList = static_cast<CUIODListCtrl*>(pWnd);
61 return pList ? pList->SelectCurrentTarget(&Info) : DROPEFFECT_NONE;
64 BOOL CListDropTarget::OnDrop( CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point )
66 CUI_ImageDropTarget::OnDrop(pWnd,pDataObject,dropEffect,point);
68 TRACE0("CListDropTraget - OnDrop\n");
69 // should be list control
70 CUIODListCtrl *pList = static_cast<CUIODListCtrl*>(pWnd);
74 int iItem = pList->HitTest(point, &flags);
75 CDD_OleDropTargetInfo Info(pWnd->GetSafeHwnd(),point,pDataObject);
76 Info.SetDropEffect(dropEffect);
78 Info.SetKeyboardState(m_dwKeyboardState);
79 // alert control first otherwise parent
80 if (!pWnd->SendMessage(WM_APP_OLE_DD_DROP,(WPARAM)&Info))
81 return pWnd->GetParent()->SendMessage(WM_APP_OLE_DD_DROP,(WPARAM)&Info);
83 return CUI_ImageDropTarget::OnDrop(pWnd,pDataObject,dropEffect,point);