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


C++ COleDataObject类代码示例

本文整理汇总了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;
}
开发者ID:rickerliang,项目名称:OpenNT,代码行数:58,代码来源:oledlgs1.cpp

示例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();

	}
}
开发者ID:moodboom,项目名称:Reusable,代码行数:60,代码来源:OleListCtrl.cpp

示例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; 
}
开发者ID:jithuin,项目名称:infogeezer,代码行数:55,代码来源:RulerRichEdit.cpp

示例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);
    }
}
开发者ID:jiayuehua,项目名称:InsideVC,代码行数:11,代码来源:ex27bView.cpp

示例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 );
}
开发者ID:moodboom,项目名称:Reusable,代码行数:20,代码来源:OleListCtrl.cpp

示例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);
}
开发者ID:jiayuehua,项目名称:InsideVC,代码行数:13,代码来源:ex27bView.cpp

示例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;
}
开发者ID:KnowNo,项目名称:test-code-backup,代码行数:51,代码来源:BmpCtxMenuExt.cpp

示例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;
}
开发者ID:mbentz80,项目名称:jzigbeercp,代码行数:15,代码来源:mfcterm.cpp

示例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;
}
开发者ID:LjApps,项目名称:eMule-VeryCD,代码行数:33,代码来源:DropTarget.cpp

示例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;
}
开发者ID:wanglaichen2,项目名称:Mfc_Gui,代码行数:27,代码来源:DrawVw.cpp

示例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;
}
开发者ID:aolko,项目名称:construct,代码行数:20,代码来源:ddmgr.cpp

示例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);
}
开发者ID:Spritutu,项目名称:AiPI-1,代码行数:17,代码来源:OXMulticlipboardDlg.cpp

示例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
}
开发者ID:YangJinWen,项目名称:H264BSAnalyzer,代码行数:44,代码来源:hexeditctrl.cpp

示例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;
	}
开发者ID:Leoyuseu,项目名称:CodeHub,代码行数:19,代码来源:zstringEx.cpp

示例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;
}
开发者ID:0anion0,项目名称:IBN,代码行数:20,代码来源:SITE.CPP


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