本文整理汇总了C++中COleDataSource::CacheData方法的典型用法代码示例。如果您正苦于以下问题:C++ COleDataSource::CacheData方法的具体用法?C++ COleDataSource::CacheData怎么用?C++ COleDataSource::CacheData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类COleDataSource
的用法示例。
在下文中一共展示了COleDataSource::CacheData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PrepareDataSource
COleDataSource* CModuleWnd::PrepareDataSource()
{
ASSERT(m_pCurrentDocument != NULL);
int nSelectedObjects = GetListCtrl()->GetSelectedCount();
if (nSelectedObjects < 1)
return NULL;
STGMEDIUM stgMedium;
COleDataSource* pDataSource;
pDataSource = new COleDataSource;
if(pDataSource == NULL)
{
AfxThrowMemoryException();
}
if (!GetSelectModuleData(&stgMedium))
{
delete pDataSource;
return NULL;
}
pDataSource->CacheData(CDevDoc::m_cfDocData, &stgMedium);
GetDragInfoData(&stgMedium);
pDataSource->CacheData(CLayoutView::m_cfDragInfo, &stgMedium);
return pDataSource;
}
示例2: GetDocument
// helper function used for clipboard and drag-drop
COleDataSource* CEx27bView::SaveObject()
{
TRACE("Entering CEx27bView::SaveObject\n");
CEx27bDoc* pDoc = GetDocument();
if (pDoc->m_lpOleObj != NULL) {
COleDataSource* pSource = new COleDataSource();
// CODE FOR OBJECT DATA
FORMATETC fmte;
SETFORMATETC(fmte, m_cfEmbedded, DVASPECT_CONTENT, NULL,
TYMED_ISTORAGE, -1);
STGMEDIUM stgm;
stgm.tymed = TYMED_ISTORAGE;
stgm.pstg = pDoc->m_pTempStgSub;
stgm.pUnkForRelease = NULL;
pDoc->m_pTempStgSub->AddRef(); // must do both!
pDoc->m_pTempStgRoot->AddRef();
pSource->CacheData(m_cfEmbedded, &stgm, &fmte);
// metafile needed too
MakeMetafilePict(pSource);
// CODE FOR OBJECT DESCRIPTION DATA
HGLOBAL hObjDesc = ::GlobalAlloc(GMEM_SHARE, sizeof(OBJECTDESCRIPTOR));
LPOBJECTDESCRIPTOR pObjDesc =
(LPOBJECTDESCRIPTOR) ::GlobalLock(hObjDesc);
pObjDesc->cbSize = sizeof(OBJECTDESCRIPTOR);
pObjDesc->clsid = CLSID_NULL;
pObjDesc->dwDrawAspect = 0;
pObjDesc->dwStatus = 0;
pObjDesc->dwFullUserTypeName = 0;
pObjDesc->dwSrcOfCopy = 0;
pObjDesc->sizel.cx = 0;
pObjDesc->sizel.cy = 0;
pObjDesc->pointl.x = 0;
pObjDesc->pointl.y = 0;
::GlobalUnlock(hObjDesc);
pSource->CacheGlobalData(m_cfObjDesc, hObjDesc);
return pSource;
}
return NULL;
}
示例3: GetCharFormatSelection
BOOL CBCGPMSOffice2007DemoView::InsertBitmap (UINT uiBmpResID)
{
CWaitCursor wait;
CBitmap bmp;
if (!bmp.LoadBitmap(uiBmpResID))
{
return FALSE;
}
COleDataSource* pDataSrc = new COleDataSource;
COleDataObject* pData = new COleDataObject;
CBCGPMSOffice2007DemoCntrItem* pItem = NULL;
TRY
{
WPD_CHARFORMAT cf = GetCharFormatSelection();
STGMEDIUM stgm;
stgm.hGlobal = bmp.GetSafeHandle();
stgm.tymed = TYMED_GDI;
stgm.pUnkForRelease = NULL;
pDataSrc->CacheData (CF_BITMAP, &stgm);
LPDATAOBJECT lpdata;
if (FAILED (pDataSrc->m_xDataObject.QueryInterface (IID_IDataObject,
(LPVOID FAR*) &lpdata)))
{
AfxThrowUserException();
}
pData->Attach (lpdata);
CBCGPMSOffice2007DemoDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pItem = new CBCGPMSOffice2007DemoCntrItem (NULL, pDoc);
ASSERT_VALID(pItem);
if (!pItem->CreateStaticFromData (pData))
{
AfxThrowUserException();
}
pItem->m_uiCategoryID = uiBmpResID;
InsertItem (pItem);
pDoc->UpdateAllViews (this);
SetCharFormat (cf);
SyncFont ();
}
CATCH(CException, e)
{
if (pItem != NULL)
{
ASSERT_VALID(pItem);
pItem->Delete ();
}
delete pData;
delete pDataSrc;
return FALSE;
}
END_CATCH
delete pData;
delete pDataSrc;
CMainFrame* pMainFrame = ((CMainFrame*) GetTopLevelFrame ());
ASSERT_VALID (pMainFrame);
pMainFrame->ActivateRibbonContextCategory (uiBmpResID);
return TRUE;
}