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


C++ COleDataSource::CacheGlobalData方法代码示例

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


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

示例1: OnEditCopy

void CHexEdit::OnEditCopy() 
{
	COleDataSource*		pSource = new COleDataSource();
	EmptyClipboard();
	int	dwLen = GetSelLength();
	HGLOBAL		hMemb = ::GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE|GMEM_ZEROINIT, dwLen);
	HGLOBAL		hMema = ::GlobalAlloc(GMEM_MOVEABLE|GMEM_DDESHARE|GMEM_ZEROINIT, (dwLen) * 3);
	if (!hMemb || !hMema) 
		return;
	LPBYTE	p = (BYTE*)::GlobalLock(hMemb);
	// copy binary
	memcpy(p, m_pData+m_selStart, dwLen);
	::GlobalUnlock(hMemb);
	p = (BYTE*)::GlobalLock(hMema);
	// copy ascii
	memcpy(p, m_pData+m_selStart, dwLen);
	::GlobalUnlock(hMema);
	for(int	 i = 0; i < dwLen;i++)
	{
		if(m_currentMode != EDIT_ASCII)
		{
			TOHEX(m_pData[m_selStart+i], p);
			*p++ = ' ';
		}
		else
			if(!isprint(*p))
				*p++ = '.';
	}
	pSource->CacheGlobalData(RegisterClipboardFormat("BinaryData"), hMemb);	
	pSource->CacheGlobalData(CF_TEXT, hMema);	
	pSource->SetClipboard();
}
开发者ID:YangJinWen,项目名称:H264BSAnalyzer,代码行数:32,代码来源:hexeditctrl.cpp

示例2: OnBegindrag

void CExplorerTestView::OnBegindrag(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
	// TODO: Add your control notification handler code here
	int				nItem = -1;
	CObList			fileList;
	LIST_VIEW*		pListView;
	CListCtrl&		listCtrl = GetListCtrl();
	CSharedFile		sharedFile;
	COleDataSource*	dataSource = new COleDataSource;

	while((nItem = listCtrl.GetNextItem(nItem, LVNI_SELECTED)) != -1)
	{
		pListView = (LIST_VIEW*)listCtrl.GetItemData(nItem);
		fileList.AddTail((CObject*)pListView);
	}

	CArchive	ar(&sharedFile, CArchive::store);
	
	CExplorerTestDoc*	pDoc = (CExplorerTestDoc*)GetDocument();
	pDoc->SetCopyFileList(&fileList);
	pDoc->SerializeCopyFiles(ar);

	ar.Close();

	dataSource->CacheGlobalData(m_cbFormat, sharedFile.Detach());
	dataSource->DoDragDrop();

	delete dataSource;

	*pResult = 0;
}
开发者ID:gawallsibya,项目名称:BIT_MFC-CShap-DotNet,代码行数:32,代码来源:EXPLORERTESTVIEW.CPP

示例3: OnEditCopy

void CUIDesignerView::OnEditCopy()
{
	ASSERT(m_cfUI != NULL);

	TiXmlDocument xmlDoc;
	TiXmlDeclaration Declaration("1.0","utf-8","yes");
	xmlDoc.InsertEndChild(Declaration);
	TiXmlElement* pCopyElm = new TiXmlElement("UICopy");
	CopyUI(pCopyElm);
	xmlDoc.InsertEndChild(*pCopyElm);
	TiXmlPrinter printer;
	xmlDoc.Accept(&printer);
	delete pCopyElm;
	CSharedFile file(GMEM_MOVEABLE, printer.Size() + 1);
	file.Write(printer.CStr(), printer.Size());
	file.Write("\0", 1);
	COleDataSource* pDataSource = NULL;
	TRY
	{
		pDataSource = new COleDataSource;
		pDataSource->CacheGlobalData(m_cfUI, file.Detach());
		pDataSource->SetClipboard();
	}
	CATCH_ALL(e)
	{
		delete pDataSource;
		THROW_LAST();
	}
	END_CATCH_ALL
}
开发者ID:pyq881120,项目名称:urltraveler,代码行数:30,代码来源:UIDesignerView.cpp

示例4: OnItemClick

HRESULT __stdcall CXMiLFilesControl::OnItemClick(DWORD item)
{
#if 0
	HGLOBAL hData = BuildSelectedFilesClipboard();
	if (hData)
	{
		CMyDropSource*  dropSource = new CMyDropSource;
		CMyDataObject* dataObject = new CMyDataObject;

		STGMEDIUM	stg = {0};
		stg.tymed = TYMED_HGLOBAL;
		stg.hGlobal = hData;
		stg.pUnkForRelease = NULL;
		
		FORMATETC	etc = {0};
		etc.cfFormat = CF_HDROP;//CF_UNICODETEXT;//49285;//RegisterClipboardFormat(CFSTR_SHELLURL);//CF_TEXT;
		etc.tymed = TYMED_HGLOBAL;
		etc.ptd = NULL;
		etc.dwAspect = DVASPECT_CONTENT;
		etc.lindex = -1;

		dataObject->SetData(&etc, &stg, TRUE);

		DWORD dropEffect = 0;
		HRESULT hr = ::DoDragDrop(dataObject, dropSource, DROPEFFECT_LINK | DROPEFFECT_COPY | DROPEFFECT_MOVE, &dropEffect);

		if (hr == DRAGDROP_S_DROP)
		{
			if (dropEffect/* & DROPEFFECT_MOVE*/)
			{
			}
		}

		GlobalFree(hData);

	//	delete dataObject;
	//	delete dropSource;

#if 0
		COleDataSource source;
		source.CacheGlobalData(CF_HDROP, hData, NULL);

		if (source.DoDragDrop(DROPEFFECT_COPY | DROPEFFECT_MOVE, NULL, NULL) == DROPEFFECT_COPY)
		{
		}

		source.Empty();
#endif
					
		GlobalFree(hData);
	}
#endif

	return S_OK;
}
开发者ID:sigurdle,项目名称:FirstProject2,代码行数:55,代码来源:XMiLFilesControl.cpp

示例5: generateDataSource

COleDataSource* CArxdrawView::generateDataSource(int objType, const CRect& rect)
{
    COleDataSource* pSource = new COleDataSource();
    char buf[50];

    sprintf(buf,"%d %d %d %d %d", objType,
                               rect.left,
                               rect.top,
                               rect.right,
                               rect.bottom);

    HGLOBAL temp = GlobalAlloc(GHND, strlen(buf)+1);
    char *data = (char*) GlobalLock(temp);
    strcpy(data, buf);
    GlobalUnlock(temp);
    pSource->CacheGlobalData(CF_TEXT, temp);
    
    return pSource;                               
}
开发者ID:kevinzhwl,项目名称:ObjectARXMod,代码行数:19,代码来源:arxdrawview.cpp

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

示例7: OnCopyToClipboard

void CAboutDlg::OnCopyToClipboard()
{
    CStringW info = m_appname;
    info += _T("\n----------------------------------\n\n");
    info += _T("Build information:\n");
    info += _T("    Version:            ") + m_strBuildNumber + _T("\n");
    info += _T("    Compiler:           ") + m_MPCCompiler + _T("\n");
    info += _T("    Build date:         ") + m_buildDate + _T("\n\n");
#ifndef MPCHC_LITE
    info += _T("LAV Filters:\n");
    info += _T("    LAV Splitter:       ") + CFGFilterLAV::GetVersion(CFGFilterLAV::SPLITTER) + _T("\n");
    info += _T("    LAV Video:          ") + CFGFilterLAV::GetVersion(CFGFilterLAV::VIDEO_DECODER) + _T("\n");
    info += _T("    LAV Audio:          ") + CFGFilterLAV::GetVersion(CFGFilterLAV::AUDIO_DECODER) + _T("\n");
    info += _T("    FFmpeg compiler:    ") + CString(g_Gcc_Compiler) + _T("\n\n");
#endif
    info += _T("Operating system:\n");
    info += _T("    Name:               ") + m_OSName + _T("\n");
    info += _T("    Version:            ") + m_OSVersion + _T("\n");

    COleDataSource* pData = DEBUG_NEW COleDataSource();

    int len = info.GetLength() + 1;
    HGLOBAL hGlob = GlobalAlloc(GMEM_FIXED, len * sizeof(WCHAR));

    if (pData && hGlob) {
        wcscpy_s((WCHAR*)hGlob, len, (LPCWSTR)info);

        pData->CacheGlobalData(CF_UNICODETEXT, hGlob);

        // The system will take care of removing the allocated memory
        pData->SetClipboard();
    } else if (pData) {
        delete pData;
    } else if (hGlob) {
        GlobalFree(hGlob);
    }
}
开发者ID:JavanWang,项目名称:mpc-hc,代码行数:37,代码来源:AboutDlg.cpp

示例8: OnLvnBegindrag

void CGumpListView::OnLvnBegindrag(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
	*pResult = 0;

	
	COleDataSource srcItem;
	CString sType = _T("");
	HGLOBAL hTextData = 0;	

	CSharedFile clipb (GMEM_MOVEABLE|GMEM_DDESHARE|GMEM_ZEROINIT);

	dynDropSource.nControlType = DYN_PICTURE;

	CString strText;
	strText.Format("%d",0);
	sType = strText;

	clipb.Write(sType, sType.GetLength()*sizeof(TCHAR));
	hTextData = clipb.Detach();

	srcItem.CacheGlobalData(m_nIDClipFormat, hTextData);
	srcItem.DoDragDrop(DROPEFFECT_COPY,NULL,&dynDropSource);
}
开发者ID:BackupTheBerlios,项目名称:iris-svn,代码行数:24,代码来源:GumpListView.cpp

示例9: DoDrag


//.........这里部分代码省略.........
    if ( !hgDrop )
        return;

    pDrop = (DROPFILES*) GlobalLock ( hgDrop );

    if ( !pDrop )
    {
        GlobalFree ( hgDrop );
        return;
    }

    // Fill in the DROPFILES struct.
    pDrop->pFiles = sizeof(DROPFILES);

    // If we're compiling for Unicode, set the Unicode flag in the struct to
    // indicate it contains Unicode strings.
#ifdef _UNICODE
    pDrop->fWide = TRUE;
#endif;

    // Copy all the filenames into memory after the end of the DROPFILES struct.
    pos = lsDraggedFiles.GetHeadPosition();
    pszBuff = (TCHAR*) (LPBYTE(pDrop) + sizeof(DROPFILES));

    while ( pos )
    {
        lstrcpy ( pszBuff, (LPCTSTR) lsDraggedFiles.GetNext ( pos ) );
        pszBuff = 1 + _tcschr ( pszBuff, '\0' );
    }

    GlobalUnlock ( hgDrop );

    // Put the data in the data source.
    datasrc.CacheGlobalData ( CF_HDROP, hgDrop, &etc );

    // Add in our own custom data, so we know that the drag originated from our
    // window.  CMyDropTarget::DragEnter() checks for this custom format, and
    // doesn't allow the drop if it's present.  This is how we prevent the user
    // from dragging and then dropping in our own window.
    // The data will just be a dummy bool.
    HGLOBAL hgBool;

    hgBool = GlobalAlloc ( GHND | GMEM_SHARE, sizeof(bool) );

    if ( NULL == hgBool )
    {
        GlobalFree ( hgDrop );
        return;
    }

    // Put the data in the data source.
    etc.cfFormat = m_DropID;
    datasrc.CacheGlobalData ( m_DropID, hgBool, &etc );

    // Start the drag 'n' drop!
    DROPEFFECT dwEffect = datasrc.DoDragDrop ( DROPEFFECT_COPY | DROPEFFECT_MOVE );

    // If the DnD completed OK, we remove all of the dragged items from our
    // list.
    switch ( dwEffect )
    {
    case DROPEFFECT_COPY:
    case DROPEFFECT_MOVE:
    {
        // the copy completed successfully
        // do whatever we need to do here
开发者ID:BackupTheBerlios,项目名称:musik,代码行数:67,代码来源:MusikSourcesCtrl.cpp

示例10: OnTvnBegindrag


//.........这里部分代码省略.........
				csIconName = m_csaL3IconName.GetAt(i);
				csBlockName = m_csaL3MenuName.GetAt(i); // Needs to be set to trigger a subsystem drop action
			}
		}

		// next check if a level3 item is selected
		for (int i=0; i<m_iL4MenuSize; i++) {
			if (m_hItemClicked==forthlev[i]) {
				csIconName = m_csaL4IconName.GetAt(i);
				csBlockName = m_csaL4MenuName.GetAt(i);// Needs to be set to trigger a subsystem drop action
			}
		}


		LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);

		//NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
		*pResult = 0;
#ifdef  LEGACY
		// Create the drag&drop source and data objects
		COleDropSource *pDropSource = new COleDropSource;
		COleDataSource *pDataSource = new COleDataSource;
#endif
		// now determine which rows are selected
		// here it's a dirty copy from the CodeGurus's 
		// CListCtrl section
		//int idx = GetSelectedItem(); 

		// nothing selected (must be for dragging)
		// or error while registering the clipboard format
		if (/*idx == -1 ||*/ !m_DragDropFormat) 
		{
			ASSERT(FALSE);
			return;
		}

		// now grab the data (here: the count and text)
		// and serialize it into an clipboard archive
		INXString Data;

		// getting the column count, thanks Zafir!
	//	CHeaderCtrl* pHeader = (CHeaderCtrl*)m_Table.GetDlgItem(0);

		//int number = m_Table.GetSelectedCount(),
		//	colCou = pHeader?pHeader->GetItemCount():0;
/* This is some rubbish serialisation that is needed to retrieve data from files in the draw windows etc.. !!! */
		TRY
		{
			CSharedFile file(GMEM_ZEROINIT|GMEM_DDESHARE|GMEM_MOVEABLE);
			TRY
			{
				CArchive ar(&file, CArchive::store);
				TRY
				{
					INXString format = AfxGetApp()->GetProfileString("DragDrop", "Clipformat", "Common");
					if (format == "Private")
					{
						ar << (CString)csIconName;
						ar << (CString)csBlockName;
					}
					else // common data format
					{
						ar.WriteString( csIconName + "\n" + csBlockName + "\n" );
					}
					ar.Close();
				}
				CATCH_ALL(eInner)
				{
					// exception while writing into or closing the archive
					ASSERT(FALSE);
				}
				END_CATCH_ALL;
			}
			CATCH_ALL(eMiddle)
			{
				// exception in the destructor of ar
				ASSERT(FALSE);
			}
			END_CATCH_ALL;

			// put the file object into the data object
#ifdef LEGACY
			pDataSource->CacheGlobalData(m_DragDropFormat, file.Detach());
			pDataSource->DoDragDrop(DROPEFFECT_MOVE|DROPEFFECT_COPY, NULL, pDropSource);
#endif
		}
		CATCH_ALL(eOuter)
		{
			// exception while destructing the file
			ASSERT(FALSE);
		}
		END_CATCH_ALL;
#ifdef LEGACY
		delete pDropSource;
		delete pDataSource;
#endif
		*pResult = 0;

	} //	if( leafIsSelected() )
}
开发者ID:pdrezet,项目名称:brix,代码行数:101,代码来源:FunctionBlockTree.cpp

示例11: Copy

/***
	拷贝列表到剪贴板
*/
void CReportListCtrl::Copy( )
{
	// Write to shared file (REMEBER: CF_TEXT is ANSI, not UNICODE, so we need to convert)
	CSharedFile sf(GMEM_MOVEABLE|GMEM_DDESHARE|GMEM_ZEROINIT);

	// Get a tab delimited string to copy to cache
	CString str;

	// Column
	CHeaderCtrl	* pHeader	=	GetHeaderCtrl();
	int	nColCount	=	pHeader ? pHeader->GetItemCount() : 0 ;

	str.Empty();
	char buffer[256];
	LVCOLUMN	column;
	memset( &column, 0, sizeof( column ) );
	column.mask	=	LVCF_TEXT;
	column.pszText	=	buffer;
	column.cchTextMax	=	255;
	int	nColumn	=	0;
	while( GetColumn( nColumn++, &column ) )
	{
		str	+=	buffer;
		str	+=	_T("\t");
	}
	str	+=	_T("\r\n");

	sf.Write(T2A(str.GetBuffer(1)), str.GetLength());
	str.ReleaseBuffer();

	// Data
	for( int nRow = 0; nRow <GetItemCount(); nRow ++ )
	{
		str.Empty();
		for( int nCol = 0; nCol <nColCount; nCol ++ )
		{
			CString	strTemp	=	GetItemText( nRow, nCol );
			str	+=	(strTemp.IsEmpty() ? _T(" ") : strTemp );
			if( nCol != nColCount-1 )
				str	+=	_T("\t");
		}
		if( nRow != GetItemCount()-1 )
			str += _T("\r\n");
		sf.Write(T2A(str.GetBuffer(1)), str.GetLength());
		str.ReleaseBuffer();
	}
	char c = '\0';
	sf.Write(&c, 1);

	DWORD dwLen = (DWORD)sf.GetLength();
	HGLOBAL hMem = sf.Detach();
	if (!hMem) 
		return;

	hMem = ::GlobalReAlloc(hMem, dwLen, GMEM_MOVEABLE|GMEM_DDESHARE|GMEM_ZEROINIT);
	if (!hMem) 
		return;

	// Cache data
	COleDataSource* pSource = new COleDataSource();
	pSource->CacheGlobalData(CF_TEXT, hMem);
	pSource->SetClipboard();
}
开发者ID:amikey,项目名称:tradingstrategyking,代码行数:66,代码来源:SimuReport.cpp

示例12: PrepareDrop

///////////////////////////////////////////////////
//Copy this object out to the clipboard or drag/drop
//buffer based on Keith Rule's
//serialization algorithm
//from the MFC Programmer's Sourcebook website,
//and Chapter 1 of "the Essence of OLE with Active X"
//by David S. Platt.
//
//pDropEffect is only set if doing a drag-drop.
//
//You usually call this function from:
//
//1) Your view class's OnLButtonDown() method
//   when starting a drag-drop.
//
//2) Your document class when copying data
//   to the clipboard.
///////////////////////////////////////////////////
BOOL CDragDropMgr::PrepareDrop(
                   BOOL        bToClipboard,
                   LPCTSTR     lpstrFormat,
                   CObject*    pObj,
                   DROPEFFECT* pDropEffect,
                   LPCTSTR     lpstrFormat2,
                   CObject*    pObj2)
{
    if (pObj == NULL)
        return FALSE;

    CSharedFile sf(GMEM_MOVEABLE|GMEM_DDESHARE|GMEM_ZEROINIT);
    CSharedFile sf2(GMEM_MOVEABLE|GMEM_DDESHARE|GMEM_ZEROINIT);

    UINT format = ::RegisterClipboardFormat(lpstrFormat);

    if (format == 0)
        return FALSE;

    TRY
    {
        CArchive ar(&sf, CArchive::store);

        pObj->Serialize(ar);

        ar.Close();

        HGLOBAL hMem = sf.Detach();

        if (hMem == NULL)
            return FALSE;

        COleDataSource* pSrc = new COleDataSource();

        if (pSrc == NULL)
            return FALSE;
    
        pSrc->CacheGlobalData(format,hMem);

		if (pObj2) { // special case for when the second data type is a filelist
			UINT format2 = (strcmp(lpstrFormat2, "CF_HDROP") ? ::RegisterClipboardFormat(lpstrFormat2) : CF_HDROP);
			if (format2 != CF_HDROP) {
				CArchive ar2(&sf2, CArchive::store);

				pObj2->Serialize(ar2);
		
				ar2.Close();

				HGLOBAL hMem2 = sf2.Detach();

				if (hMem2 == NULL)
					return FALSE;

				pSrc->CacheGlobalData(format2,hMem2);
			}
			else { // fake file list
				DROPFILES *pDrop = (DROPFILES*)pObj2;
				HGLOBAL hgDrop = GlobalAlloc ( GHND | GMEM_SHARE, sizeof(DROPFILES)+1 );
				DROPFILES *pDrop2 = (DROPFILES*) GlobalLock ( hgDrop );
				memcpy((void*)pDrop2, (void*)pDrop, sizeof(DROPFILES)+1);
				GlobalUnlock(hgDrop);
				pSrc->CacheGlobalData(format2, hgDrop);
			}
		}
    
        //Pasting to the clipboard:
        //do not free the data source
        //(OLE will free it when no longer needed)
        if (bToClipboard)
            pSrc->SetClipboard();
    
        //Starting a drag-drop:
        //Set the type of drag-drop effect, and
        //free the data source object.
        //OLE has created a data source object in
        //the drag-drop global cache; it's
        //not our problem anymore...
        else if (pDropEffect != NULL)
        {
            *pDropEffect = pSrc->DoDragDrop();

            delete pSrc;
//.........这里部分代码省略.........
开发者ID:aolko,项目名称:construct,代码行数:101,代码来源:ddmgr.cpp


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