本文整理汇总了C++中COleDataObject类的典型用法代码示例。如果您正苦于以下问题:C++ COleDataObject类的具体用法?C++ COleDataObject怎么用?C++ COleDataObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了COleDataObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ASSERT_VALID
BOOL COlePasteSpecialDialog::CreateItem(COleClientItem *pNewItem)
{
ASSERT_VALID(this);
ASSERT(pNewItem != NULL);
ASSERT(m_ps.lpSrcDataObj != NULL);
CWaitCursor wait;
COleDataObject dataObject;
dataObject.Attach(m_ps.lpSrcDataObj, FALSE);
UINT selType = GetSelectionType();
BOOL bResult = TRUE;
switch (selType)
{
case pasteLink:
// paste link
if (!pNewItem->CreateLinkFromData(&dataObject))
{
TRACE0("Warning: CreateLinkFromData failed.\n");
bResult = FALSE;
}
break;
case pasteStatic:
if (!pNewItem->CreateStaticFromData(&dataObject))
{
TRACE0("Warning: CreateStaticFromData failed.\n");
bResult = FALSE;
}
break;
default:
ASSERT(selType == pasteNormal);
if (!pNewItem->CreateFromData(&dataObject))
{
TRACE0("Warning: CreateFromData failed.\n");
bResult = FALSE;
}
break;
}
// deal with Display As Iconic option
if (bResult && GetDrawAspect() == DVASPECT_ICON)
{
// setup iconic cache (it will draw iconic by default as well)
if (!pNewItem->SetIconicMetafile(m_ps.hMetaPict))
{
TRACE0("Warning: failed to set iconic aspect.\n");
bResult = FALSE;
}
else
{
// since picture was set OK, draw as iconic as well...
pNewItem->SetDrawAspect(DVASPECT_ICON);
}
}
return bResult;
}
示例2: Paste
//-------------------------------------------------------------------//
// Paste() //
//-------------------------------------------------------------------//
void OleListCtrl::Paste(
PASTEMODE ePasteMode
) {
COleDataObject DataObject;
if ( DataObject.AttachClipboard() )
{
// Unarchive the data into the DragData array.
ExtractDropData(
&DataObject
);
// This allows us to manipulate the drag data
// before we add it as new list items.
ProcessNewDragData(
DROPEFFECT_MOVE // dropEffect
);
// PASTE_REPLACE_ALL, PASTE_TOP default.
int nUnderCursor = 0;
switch( ePasteMode )
{
case PASTE_BOTTOM:
nUnderCursor = GetItemCount();
break;
case PASTE_REPLACE_ALL:
DeleteAllItems();
break;
case PASTE_AT_SELECTION:
nUnderCursor = GetNextItem( -1, LVNI_FOCUSED );
if ( nUnderCursor == -1 )
nUnderCursor = GetItemCount();
break;
default:
break;
}
if (
AddItemsFromDragData(
nUnderCursor,
false // bInsertAfter
)
) {
// If we added anything we need to redraw. This may also
// e.g. update the caption and icon and mark the list "dirty"
// in derived classes.
UpdateAfterDrop( nUnderCursor, true );
}
// Clear the drag contents, now that we have added them.
// Don't worry, the clipboard hasn't changed, in case we
// wanted to add the items again! :>
Items.RemoveAll();
}
}
示例3: sizeof
CLIPFORMAT CRulerRichEdit::GetAcceptableClipFormat(LPDATAOBJECT lpDataOb, CLIPFORMAT format)
{
if (m_bPasteSimple)
#ifndef _UNICODE
return CF_TEXT;
#else
return CF_UNICODETEXT;
#endif
static CLIPFORMAT cfRtf = (CLIPFORMAT)::RegisterClipboardFormat(CF_RTF);
static CLIPFORMAT cfRtfObj = (CLIPFORMAT)::RegisterClipboardFormat(CF_RETEXTOBJ);
CLIPFORMAT formats[] =
{
COutlookHelper::CF_OUTLOOK,
CF_HDROP,
cfRtf,
cfRtfObj,
CF_BITMAP,
#ifndef _UNICODE
CF_TEXT,
#else
CF_UNICODETEXT,
#endif
CF_METAFILEPICT,
CF_SYLK,
CF_DIF,
CF_TIFF,
CF_OEMTEXT,
CF_DIB,
CF_PALETTE,
CF_PENDATA,
CF_RIFF,
CF_WAVE,
CF_ENHMETAFILE
};
const long nNumFmts = sizeof(formats) / sizeof(CLIPFORMAT);
COleDataObject dataobj;
dataobj.Attach(lpDataOb, FALSE);
for (int nFmt = 0; nFmt < nNumFmts; nFmt++)
{
if (format && format == formats[nFmt])
return format;
if (dataobj.IsDataAvailable(formats[nFmt]))
return formats[nFmt];
}
// all else
return CF_HDROP;
}
示例4:
void CEx27bView::OnUpdateEditPaste(CCmdUI* pCmdUI)
{
// Make sure that object data is available
COleDataObject dataObject;
if (dataObject.AttachClipboard() &&
dataObject.IsDataAvailable(m_cfEmbedded)) {
pCmdUI->Enable(TRUE);
} else {
pCmdUI->Enable(FALSE);
}
}
示例5: OnUpdatePaste
//-------------------------------------------------------------------//
// OnUpdatePaste() //
//-------------------------------------------------------------------//
// Disable paste if nothing's available.
// Nice of MultiColumnSortListCtrl::DisplayRightClickMenu() to
// force checks for ON_UPDATE_COMMAND_UI's.
//-------------------------------------------------------------------//
void OleListCtrl::OnUpdatePaste(CCmdUI* pCmdUI)
{
bool bHaveData = false;
COleDataObject DataObject;
if ( DataObject.AttachClipboard() )
{
// Do we have OLE data in the DragData array?
bHaveData = bHaveValidDropData( &DataObject );
}
pCmdUI->Enable( bHaveData );
}
示例6: GetDocument
void CEx27bView::OnEditPaste()
{
CEx27bDoc* pDoc = GetDocument();
COleDataObject dataObject;
VERIFY(dataObject.AttachClipboard());
pDoc->DeleteContents();
DoPasteObjectDescriptor(&dataObject);
DoPasteObject(&dataObject);
SetViewAdvise();
GetSize();
pDoc->SetModifiedFlag();
pDoc->UpdateAllViews(NULL);
}
示例7: AFX_MANAGE_STATE
STDMETHODIMP CBmpCtxMenuExt::Initialize (
LPCITEMIDLIST pidlFolder,
LPDATAOBJECT pDO,
HKEY hkeyProgID )
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
COleDataObject dataobj;
HGLOBAL hglobal;
HDROP hdrop;
bool bOK = false;
dataobj.Attach ( pDO, FALSE ); // FALSE = don't release IDataObject interface when destroyed
// Get the first selected file name. I'll keep this simple and just check
// the first name to see if it's a .BMP.
hglobal = dataobj.GetGlobalData ( CF_HDROP );
if ( NULL == hglobal )
return E_INVALIDARG;
hdrop = (HDROP) GlobalLock ( hglobal );
if ( NULL == hdrop )
return E_INVALIDARG;
// Get the name of the first selected file.
if ( DragQueryFile ( hdrop, 0, m_szFile, MAX_PATH ))
{
// Is its extension .BMP?
if ( PathMatchSpec ( m_szFile, _T("*.bmp") ))
{
// Load the bitmap and attach our CBitmap object to it.
HBITMAP hbm = (HBITMAP) LoadImage ( NULL, m_szFile, IMAGE_BITMAP, 0, 0,
LR_LOADFROMFILE );
if ( NULL != hbm )
{
// We loaded the bitmap, so attach the CBitmap to it.
VERIFY( m_bmp.Attach ( hbm ) );
bOK = true;
}
}
}
GlobalUnlock ( hglobal );
return bOK ? S_OK : E_FAIL;
}
示例8:
// without this, idiot will paste files and other objects into window
HRESULT
mfc_edit_view::QueryAcceptData(LPDATAOBJECT lpdataobj,
CLIPFORMAT* lpcfFormat, DWORD reco,
BOOL fReally, HGLOBAL hMetaPict)
{
if (*lpcfFormat == CF_TEXT) return S_OK;
COleDataObject dataobj;
dataobj.Attach(lpdataobj, FALSE);
if (*lpcfFormat==0 && dataobj.IsDataAvailable(CF_TEXT)) {
*lpcfFormat = CF_TEXT;
return S_OK;
}
return S_FALSE;
}
示例9: PasteText
HRESULT CMainFrameDropTarget::PasteText(CLIPFORMAT cfData, COleDataObject& data)
{
HRESULT hrPasteResult = E_FAIL;
HANDLE hMem;
if ((hMem = data.GetGlobalData(cfData)) != NULL)
{
LPCSTR pszUrlA;
if ((pszUrlA = (LPCSTR)GlobalLock(hMem)) != NULL)
{
// skip white space
while (isspace((unsigned char)*pszUrlA))
pszUrlA++;
hrPasteResult = S_FALSE; // default: nothing was pasted
if (_strnicmp(pszUrlA, "ed2k://|", 8) == 0)
{
CString strData(pszUrlA);
int iPos = 0;
CString str = strData.Tokenize(_T("\r\n"), iPos);
while (!str.IsEmpty())
{
theApp.emuledlg->ProcessED2KLink(str);
hrPasteResult = S_OK;
str = strData.Tokenize(_T("\r\n"), iPos);
}
}
GlobalUnlock(hMem);
}
GlobalFree(hMem);
}
return hrPasteResult;
}
示例10: PasteNative
void CDrawView::PasteNative(COleDataObject& dataObject)
{
// get file refering to clipboard data
CFile* pFile = dataObject.GetFileData(m_cfDraw);
if (pFile == NULL)
return;
// connect the file to the archive
CArchive ar(pFile, CArchive::load);
TRY
{
ar.m_pDocument = GetDocument(); // set back-pointer in archive
// read the selection
m_selection.Serialize(ar);
}
CATCH_ALL(e)
{
ar.Close();
delete pFile;
THROW_LAST();
}
END_CATCH_ALL
ar.Close();
delete pFile;
}
示例11: OkToPaste
///////////////////////////////////////////////////
// Verify that data you can handle is on the clipboard.
///////////////////////////////////////////////////
BOOL CDragDropMgr::OkToPaste()
{
COleDataObject obj;
BOOL bOk = FALSE;
if (!obj.AttachClipboard())
return FALSE;
for (int i=0;i < m_nFormats.GetSize() && !bOk;i++)
{
UINT nF = m_nFormats.GetAt(i);
bOk = obj.IsDataAvailable(m_nFormats.GetAt(i));
}
return bOk;
}
示例12: ASSERT
void COXMulticlipboardDlg::ClipToPocket(COXClipPocket *pPocket)
{
//the function opens clipboard and
//calls virtual ClipObjectToPocket()
//to make copy of the clipboard data
ASSERT(pPocket);
COleDataObject clipobj;
if (!clipobj.AttachClipboard())
{
TRACE0("CMulticlipboardDlg::ClipToPocket : Failed to attach to clipboard\r\n");
return;
}
ClipObjectToPocket(pPocket, &clipobj);
}
示例13: GetClientRect
void CHexEdit::OnContextMenu(CWnd*, CPoint point)
{
// by latelee
#if 0
// CG: This block was added by the Pop-up Menu component
{
if (point.x == -1 && point.y == -1)
{
//keystroke invocation
CRect rect;
GetClientRect(rect);
ClientToScreen(rect);
point = rect.TopLeft();
point.Offset(5, 5);
}
CMenu menu;
VERIFY(menu.LoadMenu(CG_IDR_POPUP_HEX_EDIT));
CMenu* pPopup = menu.GetSubMenu(0);
ASSERT(pPopup != NULL);
pPopup->EnableMenuItem(ID_EDIT_UNDO, MF_GRAYED|MF_DISABLED|MF_BYCOMMAND);
if(!IsSelected())
{
pPopup->EnableMenuItem(ID_EDIT_CLEAR, MF_GRAYED|MF_DISABLED|MF_BYCOMMAND);
pPopup->EnableMenuItem(ID_EDIT_CUT, MF_GRAYED|MF_DISABLED|MF_BYCOMMAND);
pPopup->EnableMenuItem(ID_EDIT_COPY, MF_GRAYED|MF_DISABLED|MF_BYCOMMAND);
}
{
COleDataObject obj;
if (obj.AttachClipboard())
{
if(!obj.IsDataAvailable(CF_TEXT) && !obj.IsDataAvailable(RegisterClipboardFormat("BinaryData")))
pPopup->EnableMenuItem(ID_EDIT_PASTE, MF_GRAYED|MF_DISABLED|MF_BYCOMMAND);
}
}
pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y,
this);
}
#endif
}
示例14: tools_getClipboardText
bool zstringEx::tools_getClipboardText()
{
COleDataObject obj;
if (obj.AttachClipboard())
{
if (obj.IsDataAvailable(CF_TEXT))
{
HGLOBAL hmem = obj.GetGlobalData(CF_TEXT);
CMemFile sf((BYTE*) ::GlobalLock(hmem), (UINT)::GlobalSize(hmem));
mem_data.mem_resizenull((UINT)::GlobalSize(hmem));
sf.Read(mem_data.mem_string, (UINT)::GlobalSize(hmem));
::GlobalUnlock(hmem);
sf.Close();
return true;
}
}
return false;
}
示例15: Drop
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;
}