update for HEAD-2003091401
[reactos.git] / subsys / system / explorer / Seashell / SeaShellExt / uidragdropctrl.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 "UIDragDropCtrl.h"
21
22 #ifdef _DEBUG
23 #define new DEBUG_NEW
24 #undef THIS_FILE
25 static char THIS_FILE[] = __FILE__;
26 #endif
27
28 /////////////////////////////////////////////////////////////////////////////
29 // CDragDropCtrl
30
31 CDragDropCtrl::CDragDropCtrl()
32 {
33         m_dwKeyboardState = 0;
34 }
35
36 CDragDropCtrl::~CDragDropCtrl()
37 {
38 }
39
40 void CDragDropCtrl::OnDragLeave(CWnd* pWnd)
41 {
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);
47 }
48
49 DROPEFFECT CDragDropCtrl::OnDragEnter( CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point )
50 {
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);
56         if (bRet == FALSE)
57                 bRet = pWnd->GetParent()->SendMessage(WM_APP_OLE_DD_ENTER,(WPARAM)&Info);
58         return Info.GetDropEffect();
59 }
60
61 DROPEFFECT CDragDropCtrl::OnDragOver( CWnd* pWnd, COleDataObject* pDataObject, DWORD dwKeyState, CPoint point )
62 {
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);
68         if (bRet == FALSE)
69                 bRet = pWnd->GetParent()->SendMessage(WM_APP_OLE_DD_OVER,(WPARAM)&Info);
70         if (bRet == FALSE)
71                 return DROPEFFECT_NONE;
72         return Info.GetDropEffect();
73 }
74
75 BOOL CDragDropCtrl::OnDrop( CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point )
76 {
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
86         if (bRet == FALSE) 
87                 bRet = pWnd->GetParent()->SendMessage(WM_APP_OLE_DD_DROP,(WPARAM)&Info);
88         return bRet;
89 }
90