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;
}
예제 #2
0
파일: LeftView.cpp 프로젝트: Jester68k/DP
void CLeftView::OnEditPaste()
{
	// CG: このブロックはクリップボード アシスタント コンポーネントによって追加されました
	{
		if (OpenClipboard())
		{
			HANDLE hData = ::GetClipboardData(m_nClipboardFormat);
			if (hData != NULL)
			{
				CSharedFile memFile;
				memFile.SetHandle(hData,FALSE);
				CArchive ar(&memFile, CArchive::load);

				// データをドキュメントへシリアライズ
				DoCutCopyPaste(ar, FALSE);
				ar.Close();
				memFile.Detach();
			}
			else
				AfxMessageBox(CG_IDS_CANNOT_GET_CLIPBOARD_DATA);
			CloseClipboard();
		}
		else
			AfxMessageBox(CG_IDS_CANNOT_OPEN_CLIPBOARD);
	}

}
예제 #3
0
void CRectItem::GetNativeClipboardData(COleDataSource* pDataSource)
{
	ASSERT_VALID(this);
	ASSERT_VALID(GetDocument());

	// Create a shared file and associate a CArchive with it
	CSharedFile file;
	CArchive ar(&file, CArchive::store);

	// Serialize selected objects to the archive
	Serialize(ar);
	ar.Close();
	pDataSource->CacheGlobalData(CMainDoc::m_cfPrivate, file.Detach());
}
예제 #4
0
파일: LeftView.cpp 프로젝트: Jester68k/DP
void CLeftView::OnEditCut()
{
	// CG: このブロックはクリップボード アシスタント コンポーネントによって追加されました
	{
		CSharedFile	memFile;
		CArchive ar(&memFile, CArchive::store|CArchive::bNoFlushOnDelete);

		// シリアライズ データをアーカイブ オブジェクトへ
		DoCutCopyPaste(ar, TRUE);

		ar.Flush();

		HGLOBAL hData = memFile.Detach();
		if (OpenClipboard())
		{
			::SetClipboardData(m_nClipboardFormat, hData);
			CloseClipboard();
		}
		else
			AfxMessageBox(CG_IDS_CANNOT_OPEN_CLIPBOARD);
	}
}
예제 #5
0
/*	CPBaseDataSource method that reads the serialized data from the
			memory file specified by <p hData.

	@rdesc	The list of objects serialized out of the memory file.

	@devnote The list returned has been dynamically allocated and it is the
			 responsibility of the caller to free its memory.
*/
CFrogOleDataList * CPBaseDataSource::DeSerialize(
	HANDLE hData )	// @parm A handle to a memory file containing the data.
{
	// associate global memory handle with shared memory file
	CSharedFile mf;
	mf.SetHandle(hData);

	CFrogOleDataList *pList = NULL;
	TRY
	{ 
		// read from shared memory file into object list
		CArchive ar (&mf, CArchive::load);
		pList = new CFrogOleDataList;
		pList->Serialize (ar);
		// disconnect archive from shared memory file
		ar.Close();
	}
	CATCH(CArchiveException, archExcept)
	{
		CBExceptionReporter::ArchiveException(archExcept);
		delete pList;
		pList = NULL;
	}
예제 #6
0
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);
}
예제 #7
0
//-------------------------------------------------------------------//
// ArchiveAndRenderClipFormats()													//
//-------------------------------------------------------------------//
// This routine takes the drag data, provided within the members of 
// this object by the object that owns this one, creates a memory 
// file and archive to process the data, and renders the data to the 
// clipboard using the supplied data source.  The data will then
// be available for drop targets to extract it.
// The clipboard formats associated with the data include the
// CF_OLE_DRAG_DATA type, which identifies the data as a
// OleDragData object.  The extraction always uses the 
// CF_OLE_DRAG_DATA type.
//-------------------------------------------------------------------//
void OleListCtrl::ArchiveAndRenderClipFormats(
	COleDataSource* pSource
) {
	
	// Prepare to archive the data.
	// Create a shared file and associate a CArchive with it
	CSharedFile DataMemFile;
	
	// TO DO
	// BoundsChecker is telling us, the first time we
	// hit this code and close the archive, that the 
	// flags are illegal.  What flags is it referring to?
	// The store flag here?  Research.
	CArchive DataArchive( &DataMemFile, CArchive::store );

	// Archive the count.
	int nCount = Items.GetSize();
	DataArchive.Write( &nCount, sizeof( nCount ) );

	// Loop through the items array and archive.
	int i;
	OleDragItem* pItem;
	for ( i = 0; i < nCount; i++ ) {

		pItem = &( Items[i] );
		
		// Write the next item.		
		// This MUST MATCH the order in the read function.

		// First, write the column names.
		DataArchive << pItem->m_strName;

		// Set the item's checked state.
		DataArchive << (BYTE)pItem->m_bChecked;

		// Now dump any data that is attached via the lParam.
		// This is a virtual function that is overridden in derived
		// classes so that we dump the actual contents of the data
		// pointed to by the lParam, if any.
		WriteLParam( &DataArchive, pItem->m_lParam );

	}

	// We need to close the archive before caching the data.
	DataArchive.Close();

	// We now render a clip format that contains the entire
	// drag data array.  This format is common to all classes
	// that use OleDragData.
	// CLIPFORMAT ClipFormat = CF_OLE_DRAG_DATA;
	CLIPFORMAT ClipFormat = RegisterClipboardFormat( cszOleDragData );
	
	// This immediately renders the data.
	// DelayRenderData is an alternative that delays rendering of the 
	// data until needed.
	pSource->CacheGlobalData( ClipFormat, DataMemFile.Detach() );

	// Note: Don't free the global allocation, that will be done by the 
	// data source.
	
	// TO DO
	// TEXT CLIPFORMAT CF_TEXT

	// Clear the items array, now that we have archived it.
	Items.RemoveAll();

}
예제 #8
0
void CSimpleReport::Paste()
{
	if (IsVirtualMode())
		return;

	CWaitCursor _WC;

	CLIPFORMAT uCF_Records = (CLIPFORMAT)::RegisterClipboardFormat(XTPREPORTCTRL_CF_RECORDS);

	CXTPReportRecords arRecords;
	BOOL bTryPasteFromText = TRUE;

	// Retrieve text from the clipboard
	if (!OpenClipboard())
		return;

	if (::IsClipboardFormatAvailable(uCF_Records))
	{
		HGLOBAL hPasteData = ::GetClipboardData(uCF_Records);

		if (hPasteData)
		{
			bTryPasteFromText = FALSE;

			const int cErrTextSize = 1024;
			TCHAR szErrText[cErrTextSize + 1];

			CSharedFile fileSahred;
			fileSahred.SetHandle(hPasteData, FALSE);
			CArchive ar(&fileSahred, CArchive::load);

			try
			{
				CXTPPropExchangeArchive px(ar);
				BOOL bread = FALSE;
			#if _XTPLIB_VERSION_PREFIX == 1502
				bread = _ReadRecordsFromData(&px, arRecords);
			#else
				bread = _ReadRecodsFromData(&px, arRecords);
			#endif
				if (!bread)
				{
					arRecords.RemoveAll();
				}
			}
			catch(CArchiveException* pE)
			{
				if (pE->GetErrorMessage(szErrText, cErrTextSize))
				{
					TRACE(_T("EXCEPTION: CXTPReportControl::Paste() - %s\n"), szErrText);
				}
				pE->Delete();
			}
			catch(CFileException* pE)
			{
				if (pE->GetErrorMessage(szErrText, cErrTextSize))
				{
					TRACE(_T("EXCEPTION: CXTPReportControl::Paste() - %s\n"), szErrText);
				}
				pE->Delete();
			}
			catch(...)
			{
				TRACE(_T("EXCEPTION: CXTPReportControl::Paste() - Unhandled Exception!\n"));
			}

			//*********
			ar.Close(); // detach from file
			fileSahred.Detach(); //detach from data
			::GlobalUnlock(hPasteData); // unlock data
		}
	}

	UINT uCF_TText = sizeof(TCHAR) == 2 ? CF_UNICODETEXT : CF_TEXT;

	if (bTryPasteFromText && ::IsClipboardFormatAvailable(uCF_TText))
	{
		// Try to get text data from the clipboard
		HGLOBAL hglbPaste = ::GetClipboardData(uCF_TText);

		// Import Text data into the control
		if (hglbPaste != NULL)
		{
			TCHAR* lpszClipboard = (TCHAR*)GlobalLock(hglbPaste);
			BOOL bRead = FALSE;
		#if _XTPLIB_VERSION_PREFIX == 1502	 
			bRead = _ReadRecordsFromText(lpszClipboard, arRecords);
		#else
			bRead = _ReadRecodsFromText(lpszClipboard, arRecords);
		#endif
			if (!bRead)
			{
				arRecords.RemoveAll();
			}
			::GlobalUnlock(hglbPaste);
		}
	}

	::CloseClipboard();
	//////////////////////////////////////////////////////////////////////////

	CUpdateContext updateContext(this);

	// Add and Populate records
	CXTPReportRow* pRow = GetFocusedRow();
	if (pRow == NULL)
		return;

	int n = pRow->GetRecord()->GetIndex();
	int nRecordsCount = arRecords.GetCount();
	if (nRecordsCount > 0) {
		for (int i = nRecordsCount - 1; i >= 0; i--) {
			CXTPReportRecord* pRecord = arRecords.GetAt(i);
			if (pRecord) {
				CMDTARGET_ADDREF(pRecord);
				if (m_bAdd)
					GetRecords()->Add(arRecords.GetAt(i));
				else
					GetRecords()->InsertAt(n, arRecords.GetAt(i));
			}
		}
		Populate();
		_SelectRows(&arRecords);
	}
	m_bAdd = false;
}