示例#1
0
文件: SITE.CPP 项目: 0anion0/IBN
STDMETHODIMP CSite::Drop(IDataObject * pDataObject,DWORD grfKeyState, POINTL pt,DWORD * pdwEffect)
{
    COleDataObject	pData;
    pData.Attach(pDataObject,FALSE);

    FORMATETC stFormatTEXT = {CF_TEXT,NULL,DVASPECT_CONTENT,-1,TYMED_HGLOBAL};

    STGMEDIUM outData =	{0};

    if(pData.GetData(CF_TEXT,&outData,&stFormatTEXT))
    {
        _bstr_t strText = (LPCTSTR)GlobalLock(outData.hGlobal);

        m_pFR->InsertTEXT(strText);

        GlobalUnlock(outData.hGlobal);
    }

    return S_OK;
}
示例#2
0
BOOL CEx27bView::MakeMetafilePict(COleDataSource* pSource)
{
	CEx27bDoc* pDoc = GetDocument();
	COleDataObject dataObject;
	LPDATAOBJECT pDataObj; // OLE object's IDataObject interface
	VERIFY(pDoc->m_lpOleObj->QueryInterface(IID_IDataObject,
		  (void**) &pDataObj) == S_OK);
	dataObject.Attach(pDataObj);
    FORMATETC fmtem;
    SETFORMATETC(fmtem, CF_METAFILEPICT, DVASPECT_CONTENT, NULL,
        TYMED_MFPICT, -1);
    if (!dataObject.IsDataAvailable(CF_METAFILEPICT, &fmtem)) {
		TRACE("CF_METAFILEPICT format is unavailable\n");
    	return FALSE;
    }
	// Just copy the metafile handle from the OLE object
	//  to the clipboard data object
    STGMEDIUM stgmm;
	VERIFY(dataObject.GetData(CF_METAFILEPICT, &stgmm, &fmtem));
	pSource->CacheData(CF_METAFILEPICT, &stgmm, &fmtem);
	return TRUE;
}
示例#3
0
void BookmarkToolBar::OnDrop(COleDataObject *aOleDataObject, DROPEFFECT aDropEffect, CPoint aPoint)
{
    CToolBarCtrl &sToolBarCtrl = GetToolBarCtrl();

    DragImage &sDragImage = DragImage::instance();

    if (sDragImage.isMyDragging() == XPR_TRUE)
    {
        CImageList *sMyDragImage = sDragImage.getMyDragImage();
        if (XPR_IS_NOT_NULL(sMyDragImage))
        {
            sMyDragImage->EndDrag();
            sMyDragImage->DragShowNolock(XPR_FALSE);
        }
    }
    else
    {
        if (mDropTarget.isUseDropHelper() == XPR_TRUE)
            mDropTarget.getDropHelper()->DragLeave();
    }

    if (mOldInsert >= 0)
    {
        TBINSERTMARK sTbInsertMark = {0};
        sTbInsertMark.iButton = -1;
        sToolBarCtrl.SetInsertMark(&sTbInsertMark);
    }

    if (mOldBookmark >= 0)
    {
        TBBUTTON sTbButton = {0};
        sToolBarCtrl.GetButton(mOldBookmark, &sTbButton);
        sToolBarCtrl.SetState(sTbButton.idCommand, TBSTATE_ENABLED);
    }

    if (XPR_IS_NOT_NULL(mObserver))
    {
        mObserver->onBookmarkToolBarStatus(*this, -1, -1, DROPEFFECT_NONE);
    }

    COleDataObject *sOleDataObject = aOleDataObject;
    if (sOleDataObject->IsDataAvailable(mShellIDListClipFormat) == XPR_FALSE)
        return;

    // 3 Operation
    //--------------------------------------------------
    // 1. Insert Bookmark Item
    // 2. Run Program & Bookmark File
    // 3. File Operation

    STGMEDIUM sStgMedium = {0};
    FORMATETC sFormatEtc = {(CLIPFORMAT)mShellIDListClipFormat, XPR_NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
    if (sOleDataObject->GetData(mShellIDListClipFormat, &sStgMedium, &sFormatEtc) == XPR_FALSE)
        return;

    if (mOldBookmark < 0)
    {
        OnDropInsertBookmark(&sStgMedium, mOldInsert);
    }
    else
    {
        xpr_bool_t sFileOperation = XPR_FALSE;

        BookmarkItem *sBookmarkItem = BookmarkMgr::instance().getBookmark(mOldBookmark);
        if (mOldBookmark >= 0 && sBookmarkItem != XPR_NULL)
        {
            LPITEMIDLIST sFullPidl = Path2Pidl(sBookmarkItem->mPath);
            sFileOperation = (sFullPidl != XPR_NULL && IsFileSystemFolder(sFullPidl));
            COM_FREE(sFullPidl);
        }

        if (sFileOperation == XPR_TRUE)
        {
            if (aDropEffect == DROPEFFECT_LINK)
                OnDropShortcut(&sStgMedium, mOldBookmark);
            else
                OnDropFileOperation(&sStgMedium, aDropEffect, mOldBookmark);
        }
        else
        {
            OnDropTarget(sOleDataObject, aDropEffect, aPoint, mOldBookmark);
        }
    }

    if (XPR_IS_NOT_NULL(sStgMedium.pUnkForRelease))
    {
        ::ReleaseStgMedium(&sStgMedium);
    }
}
//********************************************************************************
void CBCGPImageEditDlg::OnBcgToolPaste() 
{
	CBCGPLocalResource locaRes;

	COleDataObject data;
	if (!data.AttachClipboard ())
	{
		AfxMessageBox (IDP_BCGBARRES_CANT_PASTE_BITMAP);
		return;
	}

	if (!data.IsDataAvailable (CF_BITMAP))
	{
		AfxMessageBox (IDP_BCGBARRES_CANT_PASTE_BITMAP);
		return;
	}

	tagSTGMEDIUM dataMedium;
	if (!data.GetData (CF_BITMAP, &dataMedium))
	{
		AfxMessageBox (IDP_BCGBARRES_CANT_PASTE_BITMAP);
		return;
	}

	CBitmap* pBmpClip = CBitmap::FromHandle (dataMedium.hBitmap);
	if (pBmpClip == NULL)
	{
		AfxMessageBox (IDP_BCGBARRES_CANT_PASTE_BITMAP);
		return;
	}

	BITMAP bmp;
	pBmpClip->GetBitmap (&bmp);

	CDC memDCDst;
	CDC memDCSrc;

	memDCSrc.CreateCompatibleDC (NULL);
	memDCDst.CreateCompatibleDC (NULL);
	
	CBitmap* pSrcOldBitmap = memDCSrc.SelectObject (pBmpClip);
	if (pSrcOldBitmap == NULL)
	{
		AfxMessageBox (IDP_BCGBARRES_CANT_PASTE_BITMAP);
		return;
	}

	CBitmap* pDstOldBitmap = memDCDst.SelectObject (m_pBitmap);
	if (pDstOldBitmap == NULL)
	{
		AfxMessageBox (IDP_BCGBARRES_CANT_PASTE_BITMAP);
		
		memDCSrc.SelectObject (pSrcOldBitmap);
		return;
	}

	memDCDst.FillRect (CRect (0, 0, m_sizeImage.cx, m_sizeImage.cy), 
						&globalData.brBtnFace);

	int x = max (0, (m_sizeImage.cx - bmp.bmWidth) / 2);
	int y = max (0, (m_sizeImage.cy - bmp.bmHeight) / 2);

	CBCGPToolBarImages::TransparentBlt (memDCDst.GetSafeHdc (),
		x, y, m_sizeImage.cx, m_sizeImage.cy,
		&memDCSrc, 0, 0, RGB (192, 192, 192));

	memDCDst.SelectObject (pDstOldBitmap);
	memDCSrc.SelectObject (pSrcOldBitmap);

	InvalidateRect (m_rectPreviewImage);
	m_wndLargeDrawArea.Invalidate ();
}
示例#5
0
void FileScrapDropDlg::OnDrop(COleDataObject *aOleDataObject, DROPEFFECT aDropEffect, CPoint aPoint)
{
    DragImage &sDragImage = DragImage::instance();

    if (sDragImage.isMyDragging() == XPR_TRUE)
    {
        CImageList *sMyDragImage = sDragImage.getMyDragImage();
        if (XPR_IS_NOT_NULL(sMyDragImage))
        {
            sMyDragImage->EndDrag();
            sMyDragImage->DragShowNolock(XPR_FALSE);
        }
    }
    else
    {
        if (mDropTarget.isUseDropHelper() == XPR_TRUE)
        {
            mDropTarget.getDropHelper()->DragLeave();
        }
    }

    COleDataObject *sOleDataObject = aOleDataObject;
    if (sOleDataObject->IsDataAvailable(mShellIDListClipFormat) == XPR_FALSE)
        return;

    xpr_uint_t sGroupId = FileScrap::instance().getCurGroupId();

    if (mDropTarget.isRightDrag() == XPR_TRUE)
    {
        cmd::FileScrapGroupDlg sDlg;
        if (sDlg.DoModal() != IDOK)
            return;

        xpr_uint_t sSelGroupId = sDlg.getSelGroupId();
        if (sSelGroupId != FileScrap::InvalidGroupId)
            sGroupId = sSelGroupId;
    }

    STGMEDIUM sStgMedium = {0};
    FORMATETC sFormatEtc = {mShellIDListClipFormat, XPR_NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
    if (sOleDataObject->GetData(mShellIDListClipFormat, &sStgMedium, &sFormatEtc) == XPR_FALSE)
        return;

    LPIDA sIda = (LPIDA)::GlobalLock(sStgMedium.hGlobal);
    if (XPR_IS_NOT_NULL(sIda))
    {
        xpr_sint_t sCount = sIda->cidl;
        LPCITEMIDLIST sPidl1 = XPR_NULL; // folder PIDL
        LPCITEMIDLIST sPidl2 = XPR_NULL; // item PIDL

        // get folder PIDL
        sPidl1 = (LPITEMIDLIST)(((xpr_byte_t *)sIda)+(sIda)->aoffset[0]);

        LPSHELLFOLDER sShellFolder = XPR_NULL, sShellFolderDesktop = XPR_NULL;
        ::SHGetDesktopFolder(&sShellFolderDesktop);
        HRESULT sHResult = sShellFolderDesktop->BindToObject(sPidl1, XPR_NULL, IID_IShellFolder, (LPVOID *)&sShellFolder);
        if (FAILED(sHResult) || XPR_IS_NULL(sShellFolder))
        {
            sShellFolder = sShellFolderDesktop;
            sShellFolderDesktop = XPR_NULL;
        }

        LPCITEMIDLIST *sPidls = new LPCITEMIDLIST[sCount];

        xpr_sint_t i;
        xpr_sint_t sCount2 = 0;
        for (i = 0; i < sCount; ++i)
        {
            // get item PIDL and get full-qualified PIDL
            sPidl2 = (LPCITEMIDLIST)(((xpr_byte_t *)sIda)+(sIda)->aoffset[i+1]);

            if (IsFileSystem(sShellFolder, sPidl2))
            {
                sPidls[sCount2] = sPidl2;
                sCount2++;
            }
        }

        FileScrap &sFileScrap = FileScrap::instance();

        sFileScrap.addItem(sGroupId, sShellFolder, sPidls, sCount2);

        XPR_SAFE_DELETE_ARRAY(sPidls);

        COM_RELEASE(sShellFolder);
        COM_RELEASE(sShellFolderDesktop);
        ::GlobalUnlock(sStgMedium.hGlobal);
    }

    if (XPR_IS_NOT_NULL(sStgMedium.pUnkForRelease))
    {
        ::ReleaseStgMedium(&sStgMedium);
    }
}