summaryrefslogtreecommitdiffabout
path: root/DropURL.cpp
authorMichael Krelin <hacker@klever.net>2004-07-05 01:53:09 (UTC)
committer Michael Krelin <hacker@klever.net>2004-07-05 01:53:09 (UTC)
commit5305ddd8332ebd905ebef3b8365fc0d736858a7a (patch) (unidiff)
treeba6dc874bdcb00bd2e116b377a92f347ab81a733 /DropURL.cpp
downloaddipstick-5305ddd8332ebd905ebef3b8365fc0d736858a7a.zip
dipstick-5305ddd8332ebd905ebef3b8365fc0d736858a7a.tar.gz
dipstick-5305ddd8332ebd905ebef3b8365fc0d736858a7a.tar.bz2
initial commit into svn repository
git-svn-id: http://svn.klever.net/kin/dipstick/trunk@1 fe716a7a-6dde-0310-88d9-d003556173a8
Diffstat (limited to 'DropURL.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--DropURL.cpp149
1 files changed, 149 insertions, 0 deletions
diff --git a/DropURL.cpp b/DropURL.cpp
new file mode 100644
index 0000000..9394889
--- a/dev/null
+++ b/DropURL.cpp
@@ -0,0 +1,149 @@
1// DropURL.cpp : implementation file
2//
3
4#include "stdafx.h"
5#include "Dipstick.h"
6#include "DropURL.h"
7#include "DragPad.h"
8#include "Dipstick.h"
9
10#ifdef _DEBUG
11#define new DEBUG_NEW
12#undef THIS_FILE
13static char THIS_FILE[] = __FILE__;
14#endif
15
16/////////////////////////////////////////////////////////////////////////////
17// CDropURL
18
19IMPLEMENT_DYNCREATE(CDropURL, CCmdTarget)
20
21CDropURL::CDropURL()
22 : m_Pad(NULL)
23{
24}
25
26CDropURL::~CDropURL()
27{
28}
29
30
31BEGIN_MESSAGE_MAP(CDropURL, CCmdTarget)
32 //{{AFX_MSG_MAP(CDropURL)
33 //}}AFX_MSG_MAP
34END_MESSAGE_MAP()
35
36BEGIN_INTERFACE_MAP(CDropURL, CCmdTarget)
37 INTERFACE_PART(CDropURL, IID_IDropTarget, DDropTarget)
38END_INTERFACE_MAP()
39
40/////////////////////////////////////////////////////////////////////////////
41// CDropURL message handlers
42
43STDMETHODIMP_(ULONG) CDropURL::XDDropTarget::AddRef()
44{
45 METHOD_PROLOGUE(CDropURL, DDropTarget)
46 return pThis->ExternalAddRef();
47}
48STDMETHODIMP_(ULONG) CDropURL::XDDropTarget::Release()
49{
50 METHOD_PROLOGUE(CDropURL, DDropTarget)
51 return pThis->ExternalRelease();
52}
53STDMETHODIMP_(HRESULT) CDropURL::XDDropTarget::QueryInterface(REFIID iid,void FAR* FAR * ppvObj)
54{
55 METHOD_PROLOGUE(CDropURL, DDropTarget)
56 return pThis->ExternalQueryInterface(&iid,ppvObj);
57}
58
59STDMETHODIMP_(HRESULT) CDropURL::XDDropTarget::DragEnter(IDataObject *pDataObject,DWORD grfKeyState,POINTL pt,DWORD *pdwEffect)
60{
61 METHOD_PROLOGUE(CDropURL, DDropTarget)
62 TRACE0("DragEnter\n");
63 return pThis->DragEnter(pDataObject,grfKeyState,pt,pdwEffect);
64}
65STDMETHODIMP_(HRESULT) CDropURL::XDDropTarget::DragOver(DWORD grfKeyState,POINTL pt,DWORD *pdwEffect)
66{
67 METHOD_PROLOGUE(CDropURL, DDropTarget)
68 return S_OK;
69}
70STDMETHODIMP_(HRESULT) CDropURL::XDDropTarget::DragLeave(void)
71{
72 METHOD_PROLOGUE(CDropURL, DDropTarget)
73 TRACE0("DragLeave\n");
74 return S_OK;
75}
76STDMETHODIMP_(HRESULT) CDropURL::XDDropTarget::Drop(IDataObject *pDataObject,DWORD grfKeyState,POINTL pt,DWORD *pdwEffect)
77{
78 METHOD_PROLOGUE(CDropURL, DDropTarget)
79 TRACE0("Drop\n");
80 return pThis->Drop(pDataObject,grfKeyState,pt,pdwEffect);
81}
82
83
84HRESULT CDropURL::DragEnter(IDataObject *pDataObject,DWORD grfKeyState,POINTL pt,DWORD *pdwEffect)
85{
86CString host = GetHostName(pDataObject);
87 if(host.IsEmpty()){
88 (*pdwEffect)=DROPEFFECT_NONE;
89 return S_FALSE;
90 }else{
91 (*pdwEffect)=DROPEFFECT_LINK;
92 return S_OK;
93 }
94}
95
96CString CDropURL::GetHostName(IDataObject *pDataObject,CString *_url)
97{
98FORMATETC fetc;
99 fetc.cfFormat=CF_TEXT;
100 fetc.ptd=NULL;
101 fetc.dwAspect=DVASPECT_CONTENT;
102 fetc.lindex=-1;
103 fetc.tymed=TYMED_HGLOBAL;
104STGMEDIUM stgm;
105 LPVOIDglobe = NULL;
106 CStringurl;
107CString rv;
108 stgm.pUnkForRelease=NULL;
109 do{
110 if(pDataObject->GetData(&fetc,&stgm)!=S_OK)
111 break;
112 ASSERT(stgm.tymed==TYMED_HGLOBAL);
113 if(GlobalSize(stgm.hGlobal)>=1024)
114 break;
115 VERIFY(globe=GlobalLock(stgm.hGlobal));
116 url=(LPTSTR)globe;
117 TRACE0("["+url+"]\n");
118 if(_url)
119 (*_url) = url;
120 rv = m_Pad->m_Daddy->GetHostName(url);
121 }while(FALSE);
122 if(globe)
123 GlobalUnlock(stgm.hGlobal);
124 if(stgm.pUnkForRelease)
125 stgm.pUnkForRelease->Release();
126 return rv;
127}
128
129HRESULT CDropURL::Drop(IDataObject *pDataObject,DWORD grfKeyState,POINTL pt,DWORD *pwdEffect)
130{
131CString url;
132CString host = GetHostName(pDataObject,&url);
133 if(host.IsEmpty())
134 return S_FALSE;
135 #ifdefTRUE
136 // URL Mode
137CString *u = new CString(url);
138 m_Pad->m_Daddy->PostMessage(WM_DNP_URLPING,0,(LPARAM)u);
139#else
140CString *hn = new CString(host);
141 m_Pad->m_Daddy->PostMessage(WM_DNP_HOSTPING,0,(LPARAM)hn);
142#endif
143 return S_OK;
144}
145void CDropURL::OnFinalRelease()
146{
147 TRACE0("Final Release\n");
148 CCmdTarget::OnFinalRelease();
149}