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


C++ COleDataSource类代码示例

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


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

示例1: COleDataSource

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: PrepareDataSource

void CModuleWnd::OnLibCopy()
{
	COleDataSource* pDataSource = PrepareDataSource();

	ASSERT_VALID(pDataSource);
	pDataSource->SetClipboard();
}
开发者ID:JackWangCUMT,项目名称:SuperCxHMI,代码行数:7,代码来源:ModuleWnd.cpp

示例3: ASSERT

//-------------------------------------------------------------------//
// Copy()																				//
//-------------------------------------------------------------------//
void OleListCtrl::Copy()
{
	// We provide a ClipFormat, so make sure ClipFormat is ready to go.
	ASSERT( ClipFormat != NULL );

	// Dump the current selection into drag data array.
	ExtractItemsToDragData( 
		true,
		-1				/// nUnderCursor
	);

	// To drag, we need a COleDataSource that is loaded with our data.
	// Get a new one.
	// From "Using the OLE Clipboard Mechanism" in MSDN:
	// Create an OLE data source on the heap
	// COleDataSource DataSource;
	COleDataSource* pSource = new COleDataSource;

	// Put the drag data into the DS.
	// This renders to the clipboard.
	ArchiveAndRenderClipFormats( pSource );

	// The Clipboard now owns the allocated memory
	// and will delete this data object
	// when new data is put on the Clipboard
	pSource->SetClipboard();

	// Clear the drag contents, now that we have copied them to the clipboard.
	Items.RemoveAll();

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

示例4: ASSERT

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;
}
开发者ID:JackWangCUMT,项目名称:SuperCxHMI,代码行数:30,代码来源:ModuleWnd.cpp

示例5: SaveObject

void CEx27bView::OnEditCopy() 
{
	COleDataSource* pSource = SaveObject();
	if(pSource) {
		pSource->SetClipboard(); // OLE deletes data source 
    }
}
开发者ID:jiayuehua,项目名称:InsideVC,代码行数:7,代码来源:ex27bView.cpp

示例6: ASSERT

BOOL CXTPCoreTreeControl::DragItem(CXTPCoreTreeItem* pItem, DROPEFFECT dropEffectMask)
{
	ASSERT(pItem);
	if (!pItem)
		return FALSE;

	COleDataSource ds;
	if (!pItem->PrepareDrag(ds))
		return FALSE;

	m_pDraggingItem = pItem;


	DROPEFFECT dropEffect = ds.DoDragDrop(dropEffectMask);

	BOOL bRemoved = FALSE;

	if ((dropEffect == DROPEFFECT_MOVE) && (dropEffectMask & DROPEFFECT_MOVE))
	{
		if (m_pDraggingItem)
		{
			m_pDraggingItem->Remove();
			bRemoved = TRUE;
		}
	}


	m_pDraggingItem = NULL;

	return bRemoved;
}
开发者ID:lai3d,项目名称:ThisIsASoftRenderer,代码行数:31,代码来源:XTPCoreTreeControl.cpp

示例7: ASSERT

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

示例8: GetListCtrl

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

示例9: ASSERT

void CNSToolbar2::MoveButton(int nIndex)
{
    ASSERT(nIndex >= 0 && nIndex <m_nNumButtons);

    COleDataSource * pDataSource = new COleDataSource;


    m_pButtonArray[nIndex]->FillInOleDataSource(pDataSource);

    CToolbarButton *pButton = m_pButtonArray[nIndex];

    // Don't start drag until outside this rect

    RECT rectDragStart;
    pButton->GetClientRect(&rectDragStart);
    pButton->MapWindowPoints(this, &rectDragStart);

    DROPEFFECT effect;
    CToolbarDropSource * pDropSource = new CToolbarDropSource;

    effect=pDataSource->DoDragDrop(DROPEFFECT_COPY | DROPEFFECT_LINK | DROPEFFECT_MOVE | DROPEFFECT_SCROLL | DROPEFFECT_NONE,
                                   &rectDragStart, pDropSource);


    delete pDropSource;
    delete pDataSource;

}
开发者ID:vicamo,项目名称:b2g_mozilla-central,代码行数:28,代码来源:toolbar2.cpp

示例10: ASSERT_VALID

void COleServerItem::CopyToClipboard(BOOL bIncludeLink)
{
	ASSERT_VALID(this);

	COleDataSource* pDataSource = OnGetClipboardData(bIncludeLink, NULL, NULL);

	// put it on the clipboard
	pDataSource->SetClipboard();
}
开发者ID:rickerliang,项目名称:OpenNT,代码行数:9,代码来源:olesvr2.cpp

示例11: ASSERT

DROPEFFECT COleServerItem::DoDragDrop(LPCRECT lpItemRect, CPoint ptOffset,
	BOOL bIncludeLink, DWORD dwEffects, LPCRECT lpRectStartDrag)
{
	ASSERT(AfxIsValidAddress(lpItemRect, sizeof(RECT)));
	ASSERT_VALID(this);

	ASSERT_VALID(this);

	DROPEFFECT dropEffect = DROPEFFECT_NONE;
	COleDataSource *pDataSource = NULL;
	TRY
	{
		// get clipboard data for this item
		CSize sizeItem(
			lpItemRect->right - lpItemRect->left,
			lpItemRect->bottom - lpItemRect->top);
		pDataSource = OnGetClipboardData(bIncludeLink, &ptOffset, &sizeItem);

		// add DROPEFFECT_LINK if link source is available
		LPDATAOBJECT lpDataObject = (LPDATAOBJECT)
			pDataSource->GetInterface(&IID_IDataObject);
		ASSERT(lpDataObject != NULL);
		FORMATETC formatEtc;
		formatEtc.cfFormat = (CLIPFORMAT)_oleData.cfLinkSource;
		formatEtc.ptd = NULL;
		formatEtc.dwAspect = DVASPECT_CONTENT;
		formatEtc.lindex = -1;
		formatEtc.tymed = (TYMED)-1;
		if (lpDataObject->QueryGetData(&formatEtc) == S_OK)
			dwEffects |= DROPEFFECT_LINK;

		// calculate default sensitivity rectangle
		CRect rectDrag;
		if (lpRectStartDrag == NULL)
		{
			rectDrag.SetRect(lpItemRect->left, lpItemRect->top, lpItemRect->left,
				lpItemRect->top);
			lpRectStartDrag = &rectDrag;
		}

		// do drag drop operation
		dropEffect = pDataSource->DoDragDrop(dwEffects, lpRectStartDrag);
		pDataSource->InternalRelease();
	}
	CATCH_ALL(e)
	{
		if (pDataSource != NULL)
			pDataSource->InternalRelease();

		THROW_LAST();
	}
	END_CATCH_ALL

	return dropEffect;
}
开发者ID:rickerliang,项目名称:OpenNT,代码行数:55,代码来源:olesvr2.cpp

示例12: BuildSelectedFilesClipboard

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

示例13: GetCurSel

void CButtonsTextList::OnLButtonDown(UINT nFlags, CPoint point) 
{
	CListBox::OnLButtonDown(nFlags, point);

	int iIndex = GetCurSel ();
	if (iIndex == LB_ERR)
	{
		return;
	}

	//-------------------------------------------
	// Be sure that we realy click into the item!
	//-------------------------------------------
	CRect rect;
	GetItemRect (iIndex, &rect);

	if (!rect.PtInRect (point))
	{
		return;
	}

	//-----------------------------------------------------------
	// Trigger mouse up event (to change selection notification):
	//-----------------------------------------------------------
	SendMessage (WM_LBUTTONUP, nFlags, MAKELPARAM (point.x, point.y));

	//---------------------
	// Get selected button:
	//---------------------
	CBCGPToolbarButton* pButton = (CBCGPToolbarButton*) GetItemData (iIndex);
	ASSERT_VALID(pButton);

	//--------------------------------------
	// Prepare clipboard data and start drag:
	//--------------------------------------
	COleDataSource* pSrcItem = new COleDataSource();

	pButton->m_bDragFromCollection = TRUE;
	pButton->PrepareDrag (*pSrcItem);
	pButton->m_bDragFromCollection = FALSE;

	{
		CBCGPLocalResource locaRes;
		::SetCursor (AfxGetApp ()->LoadCursor (IDC_BCGBARRES_DELETE));
	}

	pSrcItem->DoDragDrop(DROPEFFECT_COPY|DROPEFFECT_MOVE, &rect, &CBCGPToolBar::m_DropSource);
	pSrcItem->InternalRelease();
}
开发者ID:iclosure,项目名称:jframework,代码行数:49,代码来源:ButtonsTextList.cpp

示例14: if

afx_msg void
MFCQuaSymbolIndexView::OnBeginDrag(NMHDR *pnmh, LRESULT* bHandled)
{
	cerr << "MFCQuaSymbolIndexView begin drag" << endl;
	NM_TREEVIEW* tvp = (NM_TREEVIEW*)pnmh;

	if (!draggingNow) {
		if  (tvp->itemNew.lParam > QSI_SYMBOL_LPARAM ) {
			StabEnt	*s = (StabEnt *)tvp->itemNew.lParam;
			bool	draggable = false;
			UINT	dragFormat = 0;
			switch (s->type) {
			case TypedValue::S_CLIP:	// move an instance
					draggable = true;
					dragFormat = QuaDrop::clipFormat;
					break;
				case TypedValue::S_INSTANCE:	// move an instance
					draggable = true;
					dragFormat = QuaDrop::instanceFormat;
					break;
				case TypedValue::S_SAMPLE:	// create a sample instance
					draggable = true;
					dragFormat = QuaDrop::sampleFormat;
					break;
				case TypedValue::S_VOICE:	// create a voice instance
					draggable = true;
					dragFormat = QuaDrop::voiceFormat;
					break;
			}
			if (!draggable) {
				*bHandled = TRUE;
				return;
			}

			COleDataSource srcItem;

			CTreeCtrl& tree = GetTreeCtrl();
			QuaDrop::SetSymbolSource(&srcItem, dragFormat, s);
			tree.Select(tvp->itemNew.hItem, TVGN_CARET);
			selectedItem = tvp->itemNew.hItem;
			srcItem.DoDragDrop();

		}
	}

	*bHandled = 0;
}
开发者ID:dakyri,项目名称:qua,代码行数:47,代码来源:MFCQuaSymbolIndexView.cpp

示例15: generateDataSource

void CArxdrawView::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default

    CPoint local = point;
    m_lastPoint = local;

    // find out which object is selected
    // 0 = circle
    // 1 - square
    // 2 - up triangle
    // 3 - down triangle
    int objType = -1;

    if (point.x < 65)
    { // circle or square
      if (point.y < 45)
        objType = 0;
      else
        objType = 1;
    }
    else
    {
      if (point.y < 45)
        objType = 2;
      else
        objType = 3;
    }
    
    COleDataSource *pSource = generateDataSource(objType, CRect(CPoint(0,0), CSize(m_sliderVal, m_sliderVal )));
    CMyOverrideDropTarget myDT;
    CDropSource myDS;
    
    // Start overriding AutoCAD's Droptarget
    if (!acedStartOverrideDropTarget(&myDT))
        TRACE("Error in overriding Custom drop target!\n");
    
   
    DROPEFFECT dwEffect = pSource->DoDragDrop( DROPEFFECT_NONE |DROPEFFECT_MOVE | DROPEFFECT_COPY, NULL, &myDS);

    // End overriding AutoCAD default droptarget
    if (!acedEndOverrideDropTarget(&myDT))
        TRACE("Error in ending override drop target\n");

    delete pSource;
}
开发者ID:kevinzhwl,项目名称:ObjectARXMod,代码行数:46,代码来源:arxdrawview.cpp


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