// Created:
// RCS-ID: $Id$
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
-// Licence: wxWindows license
+// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// ============================================================================
#include "wx/setup.h"
-#if wxUSE_DRAG_AND_DROP
+#if wxUSE_OLE && wxUSE_DRAG_AND_DROP
+#include "wx/msw/private.h"
#include "wx/log.h"
+#ifdef __WXWINCE__
+ #include <winreg.h>
+ #include <ole2.h>
+#endif
+
#ifdef __WIN32__
#if !defined(__GNUWIN32__) || wxUSE_NORLANDER_HEADERS
+ #if wxCHECK_W32API_VERSION( 1, 0 )
+ #include "wx/msw/wrapwin.h"
+ #endif
#include <shlobj.h> // for DROPFILES structure
#endif
#else
#include "wx/dnd.h"
-#ifndef __WIN32__
- #include <ole2.h>
- #include <olestd.h>
-#endif
-
#include "wx/msw/ole/oleutils.h"
// ----------------------------------------------------------------------------
// get default drop effect for given keyboard flags
static inline DWORD GetDropEffect(DWORD flags);
+
+ DECLARE_NO_COPY_CLASS(wxIDropTarget)
};
// ----------------------------------------------------------------------------
wxIDropTarget::wxIDropTarget(wxDropTarget *pTarget)
{
- m_cRef = 0;
m_pTarget = pTarget;
m_pIDataObject = NULL;
}
POINTL pt,
DWORD *pdwEffect)
{
- wxLogDebug(wxT("IDropTarget::DragEnter"));
+ wxLogTrace(wxTRACE_OleCalls, wxT("IDropTarget::DragEnter"));
- wxASSERT( m_pIDataObject == NULL );
+ wxASSERT_MSG( m_pIDataObject == NULL,
+ _T("drop target must have data object") );
+
+ // show the list of formats supported by the source data object for the
+ // debugging purposes, this is quite useful sometimes - please don't remove
+#if 0
+ IEnumFORMATETC *penumFmt;
+ if ( SUCCEEDED(pIDataSource->EnumFormatEtc(DATADIR_GET, &penumFmt)) )
+ {
+ FORMATETC fmt;
+ while ( penumFmt->Next(1, &fmt, NULL) == S_OK )
+ {
+ wxLogDebug(_T("Drop source supports format %s"),
+ wxDataObject::GetFormatName(fmt.cfFormat));
+ }
+
+ penumFmt->Release();
+ }
+ else
+ {
+ wxLogLastError(_T("IDataObject::EnumFormatEtc"));
+ }
+#endif // 0
if ( !m_pTarget->IsAcceptedData(pIDataSource) ) {
// we don't accept this kind of data
// Notes : good place to do any clean-up
STDMETHODIMP wxIDropTarget::DragLeave()
{
- wxLogDebug(wxT("IDropTarget::DragLeave"));
+ wxLogTrace(wxTRACE_OleCalls, wxT("IDropTarget::DragLeave"));
// remove the UI feedback
m_pTarget->OnLeave();
POINTL pt,
DWORD *pdwEffect)
{
- wxLogDebug(wxT("IDropTarget::Drop"));
+ wxLogTrace(wxTRACE_OleCalls, wxT("IDropTarget::Drop"));
// TODO I don't know why there is this parameter, but so far I assume
// that it's the same we've already got in DragEnter
bool wxDropTarget::Register(WXHWND hwnd)
{
- HRESULT hr = ::CoLockObjectExternal(m_pIDropTarget, TRUE, FALSE);
+ HRESULT hr;
+
+ // May exist in later WinCE versions
+#ifndef __WXWINCE__
+ hr = ::CoLockObjectExternal(m_pIDropTarget, TRUE, FALSE);
if ( FAILED(hr) ) {
wxLogApiError(wxT("CoLockObjectExternal"), hr);
return FALSE;
}
+#endif
hr = ::RegisterDragDrop((HWND) hwnd, m_pIDropTarget);
if ( FAILED(hr) ) {
+ // May exist in later WinCE versions
+#ifndef __WXWINCE__
::CoLockObjectExternal(m_pIDropTarget, FALSE, FALSE);
-
+#endif
wxLogApiError(wxT("RegisterDragDrop"), hr);
return FALSE;
}
wxLogApiError(wxT("RevokeDragDrop"), hr);
}
+ // May exist in later WinCE versions
+#ifndef __WXWINCE__
::CoLockObjectExternal(m_pIDropTarget, FALSE, TRUE);
+#endif
m_pIDropTarget->SetHwnd(0);
}
rc = TRUE;
}
else {
- wxLogLastError(wxT("IDataObject::SetData()"));
+ wxLogApiError(wxT("IDataObject::SetData()"), hr);
}
}
else {
- wxLogLastError(wxT("IDataObject::GetData()"));
+ wxLogApiError(wxT("IDataObject::GetData()"), hr);
}
return rc;
// get the list of supported formats
size_t nFormats = m_dataObject->GetFormatCount(wxDataObject::Set);
wxDataFormat format;
- wxDataFormat *formats;
+ wxDataFormat *formats;
formats = nFormats == 1 ? &format : new wxDataFormat[nFormats];
m_dataObject->GetAllFormats(formats, wxDataObject::Set);
case DROPEFFECT_COPY:
return wxDragCopy;
+ case DROPEFFECT_LINK:
+ return wxDragLink;
+
case DROPEFFECT_MOVE:
return wxDragMove;
case wxDragCopy:
return DROPEFFECT_COPY;
+ case wxDragLink:
+ return DROPEFFECT_LINK;
+
case wxDragMove:
return DROPEFFECT_MOVE;