示例#1
0
DROPEFFECT COleServerItem::DoDragDrop(LPCRECT lpItemRect, CPoint ptOffset,
	BOOL bIncludeLink, DWORD dwEffects, LPCRECT lpRectStartDrag)
{
	ASSERT(AfxIsValidAddress(lpItemRect, sizeof(RECT)));
	ASSERT_VALID(this);

	ASSERT_VALID(this);

	DROPEFFECT dropEffect = DROPEFFECT_NONE;
	COleDataSource *pDataSource = NULL;
	TRY
	{
		// get clipboard data for this item
		CSize sizeItem(
			lpItemRect->right - lpItemRect->left,
			lpItemRect->bottom - lpItemRect->top);
		pDataSource = OnGetClipboardData(bIncludeLink, &ptOffset, &sizeItem);

		// add DROPEFFECT_LINK if link source is available
		LPDATAOBJECT lpDataObject = (LPDATAOBJECT)
			pDataSource->GetInterface(&IID_IDataObject);
		ASSERT(lpDataObject != NULL);
		FORMATETC formatEtc;
		formatEtc.cfFormat = (CLIPFORMAT)_oleData.cfLinkSource;
		formatEtc.ptd = NULL;
		formatEtc.dwAspect = DVASPECT_CONTENT;
		formatEtc.lindex = -1;
		formatEtc.tymed = (TYMED)-1;
		if (lpDataObject->QueryGetData(&formatEtc) == S_OK)
			dwEffects |= DROPEFFECT_LINK;

		// calculate default sensitivity rectangle
		CRect rectDrag;
		if (lpRectStartDrag == NULL)
		{
			rectDrag.SetRect(lpItemRect->left, lpItemRect->top, lpItemRect->left,
				lpItemRect->top);
			lpRectStartDrag = &rectDrag;
		}

		// do drag drop operation
		dropEffect = pDataSource->DoDragDrop(dwEffects, lpRectStartDrag);
		pDataSource->InternalRelease();
	}
	CATCH_ALL(e)
	{
		if (pDataSource != NULL)
			pDataSource->InternalRelease();

		THROW_LAST();
	}
	END_CATCH_ALL

	return dropEffect;
}
示例#2
0
bool FTPWindow::AcceptType(LPDATAOBJECT pDataObj) {
	FORMATETC fmtetc;

	fmtetc.ptd	    = NULL;
	fmtetc.dwAspect = DVASPECT_CONTENT;
	fmtetc.lindex   = -1;
	fmtetc.tymed	= TYMED_HGLOBAL;
	fmtetc.cfFormat = CF_HDROP;

	if (pDataObj->QueryGetData(&fmtetc) == NOERROR)
		return true;

	return false;
}
示例#3
0
DWORD CEdit::GetDropEffect( LPDATAOBJECT pIDataSource, DWORD grfKeyState, POINTL pt, CEditView *&pView, int &nBuffCol, int &nRow )
{
	DWORD dwEffect = DROPEFFECT_NONE;

	if ( !m_Buffer.IsReadOnly() )
	{
		POINT ptClient = { pt.x, pt.y };
		ScreenToClient( m_hWnd, &ptClient );
		int nView;
		if ( HitTest( ptClient.x, ptClient.y, nView ) == eEditSpace && !PtInSelection( ptClient.x, ptClient.y, FALSE ) )
		{
			FORMATETC fe = { CLIP_TEXT, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
			if ( pIDataSource->QueryGetData( &fe ) == S_OK )
			{
				RECT rcChar;
				pView = m_Views[ nView ];
				pView->GetCharPosFromPoint( ptClient.x, ptClient.y, nBuffCol, nRow, &rcChar );
				nBuffCol = m_Buffer.ConvertViewColToBufferCol( nRow, nBuffCol );
				if ( !IsRectEmpty( &rcChar ) && ( ptClient.x > ( ( rcChar.left + rcChar.right ) / 2 ) ) )
				{
					// cursor is closer to the next char
					nBuffCol += m_Buffer.GetCharSize( nRow, nBuffCol );
				}
				dwEffect = ( HAS_FLAG( grfKeyState, MK_CONTROL ) ? DROPEFFECT_COPY : DROPEFFECT_MOVE );
				if ( pView->ScrollIfNearBorder( ptClient.x, ptClient.y, TRUE ) )
				{
					dwEffect |= DROPEFFECT_SCROLL;
				}
				// make sure the effect is allowed by the source object
				m_DropTarget.NormalizeDropEffect( dwEffect );
			}
		}
	}

	return dwEffect;
}
示例#4
0
STDMETHODIMP QOleDropTarget::Drop( LPDATAOBJECT pIDataSource,
                                   DWORD grfKeyState,
                                   POINTL pt,
                                   LPDWORD pdwEffect )
{
#ifdef DEBUG_QDND_TGT
    qDebug( "QOleDropTarget::Drop( %p, %d, %d/%d, %d )",
            pIDataSource, grfKeyState, pt.x, pt.y, *pdwEffect );
    qDebug( "widget: %p, winID: %08x", widget, widget ? widget->winId() : 0 );
#endif

    if ( !qt_tryModalHelper( widget ) ) {
        *pdwEffect = DROPEFFECT_NONE;
        return NOERROR;
    }

    lastPoint = widget->mapFromGlobal( QPoint( pt.x, pt.y ) );
    // grfKeyState does not all ways contain button state in the drop so if
    // it doesn't then use the last known button state;
    if ( ( grfKeyState & KEY_STATE_BUTTON_MASK ) == 0 )
        grfKeyState |= lastKeyState & KEY_STATE_BUTTON_MASK;
    lastKeyState = grfKeyState;

    FORMATETC s_fmtMemory = { 0,
                              NULL,
                              DVASPECT_CONTENT,
                              -1,
                              TYMED_HGLOBAL };

    /* Can we convert the data? */
    bool found = false;
    QPtrList<QWindowsMime> all = QWindowsMime::all();
    for ( QWindowsMime * c = all.first(); c && !found; c = all.next() ) {
        for ( int i = 0; i < c->countCf(); i++ ) {
            int cf = c->cf( i );
            s_fmtMemory.cfFormat = cf;
            if ( pIDataSource->QueryGetData( &s_fmtMemory ) == S_OK ) {
                found = true;
                break;
            }

        }
    }
    if ( !found ) {
        return S_OK;
    }
    /* Just to be sure */
    pIDataObject = pIDataSource;

    pIDataObject->AddRef();
    QDropEvent de( lastPoint );
    de.setAction( translateKeyStateToQDropAction( grfKeyState, *pdwEffect ) );
    if ( global_src )
        global_src->setTarget( widget );
    QApplication::sendEvent( widget, &de );

    pIDataObject->Release();
    pIDataObject = NULL;

    return S_OK;
}
示例#5
0
FARINTERNAL_(BOOL) UtQueryPictFormat(LPDATAOBJECT lpSrcDataObj,
		LPFORMATETC lpforetc)
{
	FORMATETC foretctemp; // local copy of current values of format desc
	VDATEHEAP();

	LEDebugOut((DEB_ITRACE, "%p _IN UtQueryPictFormat ( %p , %p )\n",
		NULL, lpSrcDataObj, lpforetc));

	// copy format descriptor
	foretctemp = *lpforetc;

	// set values and query for our preferred formats in order of
	// preference

	
	foretctemp.cfFormat = CF_METAFILEPICT;
	foretctemp.tymed = TYMED_MFPICT;        
	if (lpSrcDataObj->QueryGetData(&foretctemp) == NOERROR)
	{
		goto QuerySuccess;
	}

	foretctemp.cfFormat = CF_ENHMETAFILE;
	foretctemp.tymed = TYMED_ENHMF;
	if( lpSrcDataObj->QueryGetData(&foretctemp) == NOERROR )
	{
		goto QuerySuccess;
	}
	foretctemp.cfFormat = CF_DIB;
	foretctemp.tymed = TYMED_HGLOBAL;       
	if (lpSrcDataObj->QueryGetData(&foretctemp) == NOERROR)
	{
		goto QuerySuccess;
	}
	
	foretctemp.cfFormat = CF_BITMAP;
	foretctemp.tymed = TYMED_GDI;   
	if (lpSrcDataObj->QueryGetData(&foretctemp) == NOERROR)
	{
		goto QuerySuccess;
	}

	LEDebugOut((DEB_ITRACE, "%p OUT UtQueryPictFormat ( %lu )\n",
		NULL, FALSE));

	return FALSE;

QuerySuccess:
	// data object supports this format; change passed in
	// format to match

	lpforetc->cfFormat = foretctemp.cfFormat;
	lpforetc->tymed = foretctemp.tymed;

	// return success

	LEDebugOut((DEB_ITRACE, "%p OUT UtQueryPictFormat ( %lu )\n",
		NULL, TRUE));

	return(TRUE);
}