当前位置: 首页>>代码示例>>C++>>正文


C++ LPDATAOBJECT::Release方法代码示例

本文整理汇总了C++中LPDATAOBJECT::Release方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDATAOBJECT::Release方法的具体用法?C++ LPDATAOBJECT::Release怎么用?C++ LPDATAOBJECT::Release使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LPDATAOBJECT的用法示例。


在下文中一共展示了LPDATAOBJECT::Release方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CanPasteLink

BOOL PASCAL COleClientItem::CanPasteLink()
{
    if (afxData.bWin31)
    {
        // We must use OleQueryLinkFromData on Win32s
        BOOL bCanPasteLink = FALSE;
        LPDATAOBJECT lpDataObject;
        if (::OleGetClipboard(&lpDataObject) == S_OK)
        {
            ASSERT(lpDataObject != NULL);
            SCODE sc = GetScode(::OleQueryLinkFromData(lpDataObject));
            bCanPasteLink = !FAILED(sc) && sc != S_FALSE;
            lpDataObject->Release();
        }
        return bCanPasteLink;
    }
    else
    {
        // it is faster and more reliable to use the Windows clipboard
        //  APIs instead of OleQueryCreateFromData.
        return IsClipboardFormatAvailable(_oleData.cfLinkSource) ||
               IsClipboardFormatAvailable(_oleData.cfFileName) ||
               IsClipboardFormatAvailable(_oleData.cfFileNameW) ||
               IsClipboardFormatAvailable(_oleData.cfObjectLink);
    }
}
开发者ID:shuowen,项目名称:OpenNT,代码行数:26,代码来源:olecli3.cpp

示例2: CanPaste

BOOL PASCAL COleClientItem::CanPaste()
{
    if (afxData.bWin31)
    {
        // We must use OleQueryCreateFromData on Win32s
        BOOL bCanPaste = FALSE;
        LPDATAOBJECT lpDataObject;
        if (::OleGetClipboard(&lpDataObject) == S_OK)
        {
            ASSERT(lpDataObject != NULL);
            SCODE sc = GetScode(::OleQueryCreateFromData(lpDataObject));
            bCanPaste = !FAILED(sc) && sc != S_FALSE;
            lpDataObject->Release();
        }
        return bCanPaste;
    }
    else
    {
        // it is faster and more reliable to use the Windows clipboard
        //  APIs instead of OleQueryCreateFromData.
        return IsClipboardFormatAvailable(_oleData.cfEmbedSource) ||
               IsClipboardFormatAvailable(_oleData.cfEmbeddedObject) ||
               IsClipboardFormatAvailable(_oleData.cfFileName) ||
               IsClipboardFormatAvailable(_oleData.cfFileNameW) ||
               IsClipboardFormatAvailable(CF_METAFILEPICT) ||
               IsClipboardFormatAvailable(CF_DIB) ||
               IsClipboardFormatAvailable(CF_BITMAP) ||
               (IsClipboardFormatAvailable(_oleData.cfOwnerLink) &&
                IsClipboardFormatAvailable(_oleData.cfNative));
    }
}
开发者ID:shuowen,项目名称:OpenNT,代码行数:31,代码来源:olecli3.cpp

示例3: _AfxLoadObjectFromStreamedPropset

BOOL AFXAPI _AfxLoadObjectFromStreamedPropset(LPUNKNOWN lpUnknown, LPSTREAM lpStream)
{
	ASSERT_POINTER(lpUnknown, IUnknown);
	ASSERT_POINTER(lpStream, IStream);

	BOOL bSuccess = FALSE;
	LPDATAOBJECT pDataObj = NULL;

	if (SUCCEEDED(lpUnknown->QueryInterface(IID_IDataObject,
			(LPVOID*)&pDataObj)))
	{
		ASSERT_POINTER(pDataObj, IDataObject);

		// Set the persistent propset format on the object.

		FORMATETC formatEtc;
		STGMEDIUM stgMedium;
		formatEtc.cfFormat = _AfxGetClipboardFormatPersistPropset();
		formatEtc.ptd = NULL;
		formatEtc.dwAspect = DVASPECT_CONTENT;
		formatEtc.lindex = -1;
		formatEtc.tymed = TYMED_ISTREAM;

		stgMedium.tymed = TYMED_ISTREAM;
		stgMedium.pstm = lpStream;
		stgMedium.pUnkForRelease = NULL;

		bSuccess = SUCCEEDED(pDataObj->SetData(&formatEtc, &stgMedium, FALSE));

		pDataObj->Release();
	}

	return bSuccess;
}
开发者ID:anyue100,项目名称:winscp,代码行数:34,代码来源:ctlpset.cpp

示例4: FreeData

void UDropTarget::FreeData()
{
    if(data) {
        data->Release();
        data = NULL;
    }
}
开发者ID:kolyden,项目名称:mirror,代码行数:7,代码来源:Win32DnD.cpp

示例5: InsertBitmap

	void CImageDataObject::InsertBitmap(IRichEditOle* pRichEditOle, HBITMAP hBitmap)
	{
		SCODE sc;

		// Get the image data object
		//
		CImageDataObject *pods = new CImageDataObject;
		LPDATAOBJECT lpDataObject;
		pods->QueryInterface(IID_IDataObject, (void **)&lpDataObject);

		pods->SetBitmap(hBitmap);

		// Get the RichEdit container site
		//
		IOleClientSite *pOleClientSite;	
		pRichEditOle->GetClientSite(&pOleClientSite);

		// Initialize a Storage Object
		//
		IStorage *pStorage;	

		LPLOCKBYTES lpLockBytes = NULL;
		sc = ::CreateILockBytesOnHGlobal(NULL, TRUE, &lpLockBytes);
		if (sc != S_OK)
			AfxThrowOleException(sc);
		ASSERT(lpLockBytes != NULL);
		
		sc = ::StgCreateDocfileOnILockBytes(lpLockBytes,
			STGM_SHARE_EXCLUSIVE|STGM_CREATE|STGM_READWRITE, 0, &pStorage);
		if (sc != S_OK)
		{
			VERIFY(lpLockBytes->Release() == 0);
			lpLockBytes = NULL;
			AfxThrowOleException(sc);
		}
		ASSERT(pStorage != NULL);

		// The final ole object which will be inserted in the richedit control
		//
		IOleObject *pOleObject; 
		pOleObject = pods->GetOleObject(pOleClientSite, pStorage);
		if(!pOleObject)
			AfxThrowOleException(sc);

		// all items are "contained" -- this makes our reference to this object
		//  weak -- which is needed for links to embedding silent update.
		OleSetContainedObject(pOleObject, TRUE);

		// Now Add the object to the RichEdit 
		//
		REOBJECT reobject;
		ZeroMemory(&reobject, sizeof(REOBJECT));
		reobject.cbStruct = sizeof(REOBJECT);
		
		CLSID clsid;
		sc = pOleObject->GetUserClassID(&clsid);
		if (sc != S_OK)
			AfxThrowOleException(sc);

		reobject.clsid = clsid;
		reobject.cp = REO_CP_SELECTION;
		reobject.dvaspect = DVASPECT_CONTENT;
		reobject.poleobj = pOleObject;
		reobject.polesite = pOleClientSite;
		reobject.pstg = pStorage;

		// Insert the bitmap at the current location in the richedit control
		//
		pRichEditOle->InsertObject(&reobject);

		// Release all unnecessary interfaces
		//
		pOleObject->Release();
		pOleClientSite->Release();
		pStorage->Release();
		lpDataObject->Release();
	}
开发者ID:mmuszkow,项目名称:wtwRSS,代码行数:77,代码来源:ImageDataObject.cpp

示例6: _AfxSaveObjectInPropset

BOOL AFXAPI _AfxSaveObjectInPropset(LPUNKNOWN pUnk, CPropertySection& psec,
	DWORD dwPropID)
{
	if (pUnk == NULL)
		return FALSE;

	ASSERT_POINTER(pUnk, IUnknown);

	BOOL bSuccess = FALSE;
	LPDATAOBJECT pDataObj;

	if (SUCCEEDED(pUnk->QueryInterface(IID_IDataObject,
			(LPVOID*)&pDataObj)))
	{
		// Get the persistent propset format from object.

		FORMATETC formatEtc;
		STGMEDIUM stgMedium;
		formatEtc.cfFormat = _AfxGetClipboardFormatPersistPropset();
		formatEtc.ptd = NULL;
		formatEtc.dwAspect = DVASPECT_CONTENT;
		formatEtc.lindex = -1;
		formatEtc.tymed = TYMED_ISTREAM;

		stgMedium.tymed = TYMED_NULL;
		stgMedium.pUnkForRelease = NULL;

		if (SUCCEEDED(pDataObj->GetData(&formatEtc, &stgMedium)))
		{
			if (stgMedium.tymed == TYMED_ISTREAM)
			{
				LPSTREAM pstm = stgMedium.pstm;

				// Seek to start of stream.
				if (SUCCEEDED(pstm->Seek(_afxLargeZero, STREAM_SEEK_SET, NULL)))
				{
					// Create a "blobbed" propset from the stream
					bSuccess = _AfxSaveStreamDataAsBlobProp(stgMedium.pstm,
						psec, dwPropID, VT_BLOB_PROPSET);
				}
			}

			// Cleanup
			ReleaseStgMedium(&stgMedium);
		}

		pDataObj->Release();
	}

	LPPERSISTSTREAM pPersStm = NULL;

	if ((!bSuccess) &&
		SUCCEEDED(pUnk->QueryInterface(IID_IPersistStream,
			(LPVOID*)&pPersStm)))
	{
		// Get the object to save itself into a stream, then store that
		// streamed data as a blob.

		ASSERT_POINTER(pPersStm, IPersistStream);
		LPSTREAM pstm = _AfxCreateMemoryStream();
		if (pstm != NULL)
		{
			if (SUCCEEDED(::OleSaveToStream(pPersStm, pstm)) &&
				SUCCEEDED(pstm->Seek(_afxLargeZero, STREAM_SEEK_SET, NULL)))
			{
				bSuccess = _AfxSaveStreamDataAsBlobProp(pstm, psec,
					dwPropID, VT_BLOB);
			}

			pstm->Release();
		}

		pPersStm->Release();
	}

	return bSuccess;
}
开发者ID:anyue100,项目名称:winscp,代码行数:77,代码来源:ctlpset.cpp

示例7: apDataSrc

BOOL CMSOffice2007DemoView::InsertBitmap(UINT uiBmpResID)
{
	CWaitCursor wait;

	CBitmap bmp;
	if (!bmp.LoadBitmap(uiBmpResID))
	{
		return FALSE;
	}

	std::auto_ptr<COleDataSource> apDataSrc(new COleDataSource);
	std::auto_ptr<COleDataObject> apData(new COleDataObject);

	TRY
	{
		STGMEDIUM stgm;
		stgm.hGlobal = bmp.GetSafeHandle();
		stgm.tymed = TYMED_GDI;
		stgm.pUnkForRelease = NULL;

		apDataSrc->CacheData(CF_BITMAP, &stgm);

		LPDATAOBJECT lpdata;

		if (FAILED(apDataSrc->m_xDataObject.QueryInterface(IID_IDataObject,
			(LPVOID FAR*) &lpdata)))
		{
			AfxThrowUserException();
		}

		apData->Attach(lpdata);
		lpdata->Release();

		CMSOffice2007DemoDoc* pDoc = GetDocument();
		ASSERT_VALID(pDoc);

		std::auto_ptr<CMSOffice2007DemoCntrItem> apItem(new CMSOffice2007DemoCntrItem(NULL, pDoc));
		ASSERT_VALID(apItem.get());

		if (!apItem->CreateStaticFromData(apData.release()))
		{
			AfxThrowUserException();
		}

		apItem->m_uiCategoryID = uiBmpResID;
		InsertItem(apItem.release());

		pDoc->UpdateAllViews(this);
	}
	CATCH(CException, e)
	{
		return FALSE;
	}
	END_CATCH

	CMainFrame* pMainFrame = ((CMainFrame*) GetTopLevelFrame());
	ASSERT_VALID(pMainFrame);

	pMainFrame->ActivateRibbonContextCategory(uiBmpResID);

	return TRUE;
}
开发者ID:jetlive,项目名称:skiaming,代码行数:62,代码来源:MSOffice2007DemoView.cpp


注:本文中的LPDATAOBJECT::Release方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。