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;

}
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;
}
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;
}
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;
}
Exemple #5
0
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;
}
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();
}
Exemple #7
0
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;
}
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;
}
void CModuleWnd::OnBegindrag(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NMLISTVIEW * phdn = (NMLISTVIEW *) pNMHDR;
	
	if (m_pCurrentDocument != NULL)
	{
		COleDataSource* pData = PrepareDataSource();
		if (pData != NULL)
		{
			m_isDragBeginer = TRUE;
			DROPEFFECT dropEffect = pData->DoDragDrop(DROPEFFECT_COPY);
			delete pData;
			m_isDragBeginer = FALSE;
		}
	}
	
	*pResult = 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);
}
Exemple #11
0
//-------------------------------------------------------------------//
// BeginDrag()
//-------------------------------------------------------------------//
// This function attempts a drag when the left button has been
// pressed on an item.  It returns true if a drag was made.
//-------------------------------------------------------------------//
BOOL OleListCtrl::BeginDrag(
	int	nUnderCursor,
	UINT	nKeyFlags
) {
	// Attempt a drag.

	/////////////////////////////////////////////////////
	// Next, we provide a ClipFormat holding the item reference.

	// Make sure ClipFormat is ready to go.
	ASSERT( ClipFormat != NULL );

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

	// To drag, we need a COleDataSource that is loaded with our data.
	// Get a new one.
	COleDataSource DataSource;

	// Put the drag data into the DS.
	ArchiveAndRenderClipFormats( &DataSource );
	
	// Now we can clear the previous drag contents.
	Items.RemoveAll();

	//	
	/////////////////////////////////////////////////////

	// Get the rectangle of the list item.
	// This will help us avoid a drag unless the user really means it.
	CRect ItemRect;
	GetItemRect( nUnderCursor, &ItemRect, LVIR_BOUNDS );
	ClientToScreen( &ItemRect );
		
	// Set flags to indicate that we are dragging.
	nListItemBeingDragged = nUnderCursor;
	bDraggingFromThisList = true;

	// Now drag it.
	DROPEFFECT deResult = DataSource.DoDragDrop(
		DROPEFFECT_COPY | DROPEFFECT_MOVE,	// | DROPEFFECT_LINK,
		ItemRect
	);

	InsertStart();

	// Indicate that we are no longer dragging.
	bDraggingFromThisList = false;
	nListItemBeingDragged = -1;

	// If it was a move, remove the item(s).
	if ( deResult == DROPEFFECT_MOVE )
	{
		// Delete the current selection, then
		// highlight the dragged items.
		DeleteOldAndHighlightNew();
	}

	// Successful drag and drop operation.
	if ( deResult != DROPEFFECT_NONE )
	{
		// Allow derived classes to do any additional clean up steps.
		FinishDragAndDrop();
	}

	InsertEnd();

	return ( deResult != DROPEFFECT_NONE );

}
Exemple #12
0
LRESULT CSQLTableWnd::OnLButtonDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	POINT point;
	point.x = (short)LOWORD(lParam);
	point.y = (short)HIWORD(lParam);

	if (!(wParam & MK_SHIFT))
	{
		for (int i = 0; i < m_columns.GetSize(); i++)
		{
			m_columns[i]->m_bSelected = false;
		}
	}

	long index = point.y/16;

	if (index >= 0 && index < m_table->Columns->Count)
	{
		m_columns[index]->m_bSelected = true;

		Invalidate();
		UpdateWindow();

		CComQIPtr<ILDOMDocument> document;
		document.CoCreateInstance(CLSID_LDOMDocument);

		VARIANT_BOOL success;
		document->loadXML(L"<columns/>", &success);

		CComQIPtr<ILDOMElement> documentElement;
		document->get_documentElement(&documentElement);

		documentElement->setAttribute(L"fromtable", m_table->Name);

		for (long i = 0; i < m_columns.GetSize(); i++)
		{
			if (m_columns[i]->m_bSelected)
			{
				CComQIPtr<ILDOMElement> element;
				document->createElement(L"column", &element);
				element->setAttribute(L"name", m_table->Columns->Item[_variant_t(index)]->Name);
				documentElement->appendChild(element, NULL);
			}
		}

		BSTR text;
		document->saveXML(NULL, &text);
		int len = SysStringLen(text);

		HGLOBAL hData = GlobalAlloc(GMEM_MOVEABLE, (len+1)*2);

		if (hData)
		{
			WCHAR* p = (WCHAR*)GlobalLock(hData);
			CopyMemory(p, text, (len+1)*2);
			GlobalUnlock(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_UNICODETEXT;//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
		}

		SysFreeString(text);
	}
	else
	{
		Invalidate();
	}

	return 0;
}
void CMusikSourcesCtrl::DoDrag( CMusikPropTreeItem* pItem )
{
    if ( !pItem )
        return;

    COleDataSource datasrc;
    HGLOBAL        hgDrop;
    DROPFILES*     pDrop;
    CStringList    lsDraggedFiles;
    POSITION       pos;
    CString        sFile;
    UINT           uBuffSize = 0;
    TCHAR*         pszBuff;
    FORMATETC      etc = { CF_HDROP, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };

    // get a list of filenames with the currently
    // selected items...
    CStdStringArray files;

    int nMode = pItem->GetPlaylistType();

    // standard playlist dragged
    if ( nMode == MUSIK_PLAYLIST_TYPE_STANDARD )
        m_Library->GetStdPlaylistFns( pItem->GetPlaylistID(), files, false );

    // now playing dragged..
    else if ( nMode == MUSIK_SOURCES_TYPE_NOWPLAYING )
    {
        if ( m_Player->GetPlaylist() )
        {
            m_Library->BeginTransaction();
            for ( size_t i = 0; i < m_Player->GetPlaylist()->GetCount(); i++ )
                files.push_back( m_Player->GetPlaylist()->GetField( i, MUSIK_LIBRARY_TYPE_FILENAME ) );
            m_Library->EndTransaction();
        }
    }

    // library playlist dragged
    else if ( nMode == MUSIK_SOURCES_TYPE_LIBRARY )
    {
        CMainFrame* pMain = (CMainFrame*)m_Parent;
        if ( pMain->m_LibPlaylist )
        {
            m_Library->BeginTransaction();
            for ( size_t i = 0; i < pMain->m_LibPlaylist->GetCount(); i++ )
                files.push_back( pMain->m_LibPlaylist->GetField( i, MUSIK_LIBRARY_TYPE_FILENAME ) );
            m_Library->EndTransaction();
        }
    }

    else if ( nMode == MUSIK_PLAYLIST_TYPE_DYNAMIC )
        MessageBox( "This operation is not supported yet.", "Musik", MB_ICONINFORMATION | MB_OK );


    if ( !files.size() )
        return;

    // CStringList containing files
    for ( size_t i = 0; i < files.size(); i++ )
    {
        lsDraggedFiles.AddTail( files.at( i ) );
        uBuffSize += files.at( i ).GetLength() + 1;
    }

    files.clear();

    // Add 1 extra for the final null char, and the size of the DROPFILES struct.
    uBuffSize = sizeof(DROPFILES) + sizeof(TCHAR) * (uBuffSize + 1);

    // Allocate memory from the heap for the DROPFILES struct.
    hgDrop = GlobalAlloc ( GHND | GMEM_SHARE, uBuffSize );

    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
        TRACE0( "DND from playlist completed successfully. The data has a new owner.\n" );
    }
    break;

    case DROPEFFECT_NONE:
    {
        // This needs special handling, because on NT, DROPEFFECT_NONE
        // is returned for move operations, instead of DROPEFFECT_MOVE.
        // See Q182219 for the details.
        // So if we're on NT, we check each selected item, and if the
        // file no longer exists, it was moved successfully and we can
        // remove it from the list.
        if ( m_IsWinNT )
        {
            // the copy completed successfully
            // on a windows nt machine.
            // do whatever we need to do here

            bool bDeletedAnything = false;
            if ( ! bDeletedAnything )
            {
                // The DnD operation wasn't accepted, or was canceled, so we
                // should call GlobalFree() to clean up.
                GlobalFree ( hgDrop );
                GlobalFree ( hgBool );

                TRACE0( "DND had a problem. We had to manually free the data.\n" );
            }
        }

        // not windows NT
        else
        {
            // We're on 9x, and a return of DROPEFFECT_NONE always means
            // that the DnD operation was aborted.  We need to free the
            // allocated memory.
            GlobalFree ( hgDrop );
            GlobalFree ( hgBool );

            TRACE0( "DND had a problem. We had to manually free the data.\n" );
        }
    }

    break;
    }
}
Exemple #14
0
void FunctionBlockTree::OnTvnBegindrag(NMHDR *pNMHDR, LRESULT *pResult)
{

	INXString csIconName = "";
	INXString csBlockName = "";

	//	if ( GetChildItem(m_hItemLeftClicked)== NULL) {
//			SetItemState( m_hItemLeftClicked, TVIS_SELECTED, TVIS_SELECTED );
	//	}

	if( !leafIsSelected() )
		// If he hasn't selected something draggable, don't let him carry 
		// on wasting his time.
		return;
	else{

	for (int i=0; i<m_iL2MenuSize; i++) {
		SetItemState( secondlev[i], !TVIS_SELECTED, TVIS_SELECTED );
	}

	// next check if a level3 item is selected
	for (int i=0; i<m_iL3MenuSize; i++) {
		SetItemState( thirdlev[i], !TVIS_SELECTED, TVIS_SELECTED );
	}
	// next check if a level3 item is selected
	for (int i=0; i<m_iL4MenuSize; i++) {
		SetItemState( forthlev[i], !TVIS_SELECTED, TVIS_SELECTED );
	}
	
	//if(m_hPrevItemClicked)
	//	SetItemState( m_hPrevItemClicked, !TVIS_SELECTED, TVIS_SELECTED );


	if(m_hItemClicked)
		SetItemState( m_hItemClicked, TVIS_SELECTED, TVIS_SELECTED );

		for (int i=0; i<m_iL2MenuSize; i++) {
			if (m_hItemClicked==secondlev[i]) {
				csIconName = m_csaL2IconName.GetAt(i);
				csBlockName = m_csaL2MenuName.GetAt(i);
			}
		}

		// next check if a level3 item is selected
		for (int i=0; i<m_iL3MenuSize; i++) {
			if (m_hItemClicked==thirdlev[i]) {
				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() )
}
Exemple #15
0
///////////////////////////////////////////////////
//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;
        }

        return TRUE;
    }   //catch

    CATCH_ALL(ce)
    {
        return FALSE;
    }
    END_CATCH_ALL
}