This commit was manufactured by cvs2svn to create branch 'captive'.
[reactos.git] / subsys / system / explorer / Seashell / SeaShellExt / uidroptarget.cpp
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
18 #include "stdafx.h"
19 #include "UICtrl.h"
20 #include "UIDragImage.h"
21 #include "UIDropTarget.h"
22 #include "UIDragDropCtrl.h"
23
24 #ifdef _DEBUG
25 #define new DEBUG_NEW
26 #undef THIS_FILE
27 static char THIS_FILE[] = __FILE__;
28 #endif
29
30 IMPLEMENT_DYNAMIC(CDD_OleDropTargetInfo,CObject)
31
32 void CListDropTarget::OnDragLeave(CWnd* pWnd)
33 {
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);
38 }
39
40 DROPEFFECT CListDropTarget::OnDragEnter( CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point )
41 {
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();
49 }
50
51 DROPEFFECT CListDropTarget::OnDragOver( CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point )
52 {
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;
62 }
63
64 BOOL CListDropTarget::OnDrop( CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point )
65 {
66         CUI_ImageDropTarget::OnDrop(pWnd,pDataObject,dropEffect,point);
67
68         TRACE0("CListDropTraget - OnDrop\n");
69         // should be list control
70         CUIODListCtrl *pList = static_cast<CUIODListCtrl*>(pWnd);
71         if (pList != NULL)      
72         {
73                 UINT flags;
74                 int iItem = pList->HitTest(point, &flags);
75                 CDD_OleDropTargetInfo Info(pWnd->GetSafeHwnd(),point,pDataObject);
76                 Info.SetDropEffect(dropEffect);
77                 Info.SetItem(iItem);
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);
82         }
83         return CUI_ImageDropTarget::OnDrop(pWnd,pDataObject,dropEffect,point);
84 }
85
86
87