X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/50c375d311ac4cefbf1ae1d11e19c9e7c00a873e..4d293f8ef41f405a8ea389ac3e00c0e268e4e305:/src/msw/ole/droptgt.cpp diff --git a/src/msw/ole/droptgt.cpp b/src/msw/ole/droptgt.cpp index 67825f8569..d1e4a97b11 100644 --- a/src/msw/ole/droptgt.cpp +++ b/src/msw/ole/droptgt.cpp @@ -30,12 +30,15 @@ #include "wx/setup.h" -#if wxUSE_DRAG_AND_DROP +#if wxUSE_OLE && wxUSE_DRAG_AND_DROP #include "wx/log.h" #ifdef __WIN32__ - #ifndef __GNUWIN32__ + #if !defined(__GNUWIN32__) || wxUSE_NORLANDER_HEADERS + #if wxCHECK_W32API_VERSION( 1, 0 ) + #include + #endif #include // for DROPFILES structure #endif #else @@ -61,7 +64,7 @@ class wxIDropTarget : public IDropTarget { public: wxIDropTarget(wxDropTarget *p); - ~wxIDropTarget(); + virtual ~wxIDropTarget(); // accessors for wxDropTarget void SetHwnd(HWND hwnd) { m_hwnd = hwnd; } @@ -139,9 +142,31 @@ STDMETHODIMP wxIDropTarget::DragEnter(IDataObject *pIDataSource, 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 @@ -157,7 +182,7 @@ STDMETHODIMP wxIDropTarget::DragEnter(IDataObject *pIDataSource, // we need client coordinates to pass to wxWin functions if ( !ScreenToClient(m_hwnd, (POINT *)&pt) ) { - wxLogLastError("ScreenToClient"); + wxLogLastError(wxT("ScreenToClient")); } // give some visual feedback @@ -197,7 +222,7 @@ STDMETHODIMP wxIDropTarget::DragOver(DWORD grfKeyState, // we need client coordinates to pass to wxWin functions if ( !ScreenToClient(m_hwnd, (POINT *)&pt) ) { - wxLogLastError("ScreenToClient"); + wxLogLastError(wxT("ScreenToClient")); } *pdwEffect = ConvertDragResultToEffect( @@ -213,7 +238,7 @@ STDMETHODIMP wxIDropTarget::DragOver(DWORD grfKeyState, // 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(); @@ -238,7 +263,7 @@ STDMETHODIMP wxIDropTarget::Drop(IDataObject *pIDataSource, 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 @@ -250,7 +275,7 @@ STDMETHODIMP wxIDropTarget::Drop(IDataObject *pIDataSource, // we need client coordinates to pass to wxWin functions if ( !ScreenToClient(m_hwnd, (POINT *)&pt) ) { - wxLogLastError("ScreenToClient"); + wxLogLastError(wxT("ScreenToClient")); } // first ask the drop target if it wants data @@ -260,14 +285,11 @@ STDMETHODIMP wxIDropTarget::Drop(IDataObject *pIDataSource, // and now it has the data wxDragResult rc = ConvertDragEffectToResult(GetDropEffect(grfKeyState)); - m_pTarget->OnData(pt.x, pt.y);//, rc); -/* + rc = m_pTarget->OnData(pt.x, pt.y, rc); if ( wxIsDragResultOk(rc) ) { // operation succeeded *pdwEffect = ConvertDragResultToEffect(rc); } -*/ - //else: *pdwEffect is already DROPEFFECT_NONE } //else: OnDrop() returned FALSE, no need to copy data @@ -308,7 +330,7 @@ bool wxDropTarget::Register(WXHWND hwnd) { HRESULT hr = ::CoLockObjectExternal(m_pIDropTarget, TRUE, FALSE); if ( FAILED(hr) ) { - wxLogApiError("CoLockObjectExternal", hr); + wxLogApiError(wxT("CoLockObjectExternal"), hr); return FALSE; } @@ -316,7 +338,7 @@ bool wxDropTarget::Register(WXHWND hwnd) if ( FAILED(hr) ) { ::CoLockObjectExternal(m_pIDropTarget, FALSE, FALSE); - wxLogApiError("RegisterDragDrop", hr); + wxLogApiError(wxT("RegisterDragDrop"), hr); return FALSE; } @@ -331,7 +353,7 @@ void wxDropTarget::Revoke(WXHWND hwnd) HRESULT hr = ::RevokeDragDrop((HWND) hwnd); if ( FAILED(hr) ) { - wxLogApiError("RevokeDragDrop", hr); + wxLogApiError(wxT("RevokeDragDrop"), hr); } ::CoLockObjectExternal(m_pIDropTarget, FALSE, TRUE); @@ -380,11 +402,11 @@ bool wxDropTarget::GetData() rc = TRUE; } else { - wxLogLastError("IDataObject::SetData()"); + wxLogApiError(wxT("IDataObject::SetData()"), hr); } } else { - wxLogLastError("IDataObject::GetData()"); + wxLogApiError(wxT("IDataObject::GetData()"), hr); } return rc; @@ -424,7 +446,8 @@ wxDataFormat wxDropTarget::GetSupportedFormat(IDataObject *pIDataSource) const // get the list of supported formats size_t nFormats = m_dataObject->GetFormatCount(wxDataObject::Set); - wxDataFormat format, *formats; + wxDataFormat format; + wxDataFormat *formats; formats = nFormats == 1 ? &format : new wxDataFormat[nFormats]; m_dataObject->GetAllFormats(formats, wxDataObject::Set); @@ -461,6 +484,9 @@ static wxDragResult ConvertDragEffectToResult(DWORD dwEffect) case DROPEFFECT_COPY: return wxDragCopy; + case DROPEFFECT_LINK: + return wxDragLink; + case DROPEFFECT_MOVE: return wxDragMove; @@ -479,6 +505,9 @@ static DWORD ConvertDragResultToEffect(wxDragResult result) case wxDragCopy: return DROPEFFECT_COPY; + case wxDragLink: + return DROPEFFECT_LINK; + case wxDragMove: return DROPEFFECT_MOVE;