Click here to Skip to main content
15,891,529 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: I'm not following the math you're doing, but maybe this will help.. Pin
Andy2025-Mar-10 8:12
Andy2025-Mar-10 8:12 
AnswerRe: Data Type Conversions Pin
Luc Pattyn5-Mar-10 4:19
sitebuilderLuc Pattyn5-Mar-10 4:19 
GeneralRe: Data Type Conversions Pin
Andy2025-Mar-10 10:48
Andy2025-Mar-10 10:48 
AnswerRe: Data Type Conversions Pin
Luc Pattyn5-Mar-10 11:38
sitebuilderLuc Pattyn5-Mar-10 11:38 
GeneralRe: Data Type Conversions Pin
Andy2025-Mar-10 22:33
Andy2025-Mar-10 22:33 
QuestionHow to receive a file name under the link? Pin
Dima Filipiuk5-Mar-10 0:58
Dima Filipiuk5-Mar-10 0:58 
AnswerRe: How to receive a file name under the link? Pin
David Crow5-Mar-10 7:07
David Crow5-Mar-10 7:07 
QuestionOLE image drag and drop between Tree controls Pin
RakeshManohar5-Mar-10 0:51
RakeshManohar5-Mar-10 0:51 
Hi,

I'm using customized CTreeCtrl for drag and drop operation.
When drag an item with image from one tree to the another tree how can i copy image
i am using DropTarget inherited from COleDropTarget.
How can i get my drop window point there in my drop target.

void CDragDropTreeCtrl::OnBegindrag(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
	HTREEITEM hTSelItem = pNMTreeView->itemNew.hItem;
	m_hDragItem = hTSelItem;
	// Highlight selected item
	SelectItem(hTSelItem);
	Select(hTSelItem, TVGN_DROPHILITE);
	
	//m_pDropWnd = this;

	if(m_pDragImage)
		delete m_pDragImage;

	m_pDragImage = CreateDragImage(hTSelItem);
	ASSERT(m_pDragImage);

	VERIFY (m_pDragImage->BeginDrag (0, CPoint (8, 8)));
	VERIFY (m_pDragImage->DragEnter (GetDesktopWindow (), ((NM_TREEVIEW *)pNMHDR)->ptDrag));
	
	m_bDragging = TRUE;
	m_hDropItem = NULL;
	m_nDropIndex = -1;
	m_pDropWnd = this;
	SetCapture();

	COleDataSource *poleSourceObj = new COleDataSource ;
	CTreeDropTarget::m_shWndTreeCtrl = m_hWnd;
	// Begin Drag operation
	DROPEFFECT dropeffect = poleSourceObj->DoDragDrop();
	// Remove the highlighting
	SendMessage(TVM_SELECTITEM, TVGN_DROPHILITE,0);
	// If user is moving item by pressing Shift, delete selected item
	if ( dropeffect == DROPEFFECT_MOVE)
		DeleteItem(hTSelItem); 
	delete poleSourceObj;
	*pResult = 0;
}
void CDragDropTreeCtrl::MouseMove(CPoint point)
{

	if(m_bDragging)
	{
		CPoint pt (point);
		ClientToScreen (&pt);
		VERIFY (m_pDragImage->DragMove (pt));
		VERIFY (m_pDragImage->DragShowNolock (FALSE));
		CWnd* pDropWnd = WindowFromPoint (pt);
		ASSERT (pDropWnd);
		if (pDropWnd != m_pDropWnd)
		{
			if (m_hDropItem)
			{
				((CDragDropTreeCtrl*)m_pDropWnd)->SelectDropTarget(NULL);
				m_hDropItem = NULL;
			}

		}
		m_pDropWnd = pDropWnd;
		pDropWnd->ScreenToClient (&pt);
		VERIFY (m_pDragImage->DragShowNolock (TRUE));
	}
}


void CTreeDropTarget::OnDragLeave( CWnd* pWnd )
{
	// Remove Highlighting 

	m_pDestTreeCtrl = (CDragDropTreeCtrl *)pWnd;
	m_pDestTreeCtrl->m_bDragging = true;
	m_pSourceTreeCtrl->m_bDragging = false;
	m_pDestTreeCtrl->m_pDragImage = m_pSourceTreeCtrl->m_pDragImage;
	//m_pDestTreeCtrl->m_pDropWnd = (CDragDropTreeCtrl *)pWnd;
	m_pDestTreeCtrl->SendMessage(TVM_SELECTITEM, TVGN_DROPHILITE,0);
	
}
DROPEFFECT CTreeDropTarget::OnDragOver( CWnd* pWnd, COleDataObject* pDataObject, 
	DWORD dwKeyState, CPoint point )
{
	
	DROPEFFECT dropeffectRet = DROPEFFECT_COPY;
	if ( (dwKeyState & MK_SHIFT) == MK_SHIFT)
		dropeffectRet = DROPEFFECT_MOVE;
	// Expand and highlight the item under the mouse and
	
	m_pDestTreeCtrl = (CDragDropTreeCtrl *)pWnd;	
	m_pDestTreeCtrl->m_pDropWnd = (CDragDropTreeCtrl *)pWnd;

	m_pSourceTreeCtrl->MouseMove(point);
	HTREEITEM hTItem = m_pDestTreeCtrl->HitTest(point);
	if ( hTItem != NULL ) 
	{
		m_pDestTreeCtrl->Expand(hTItem, TVE_EXPAND);
		m_pDestTreeCtrl->SelectDropTarget(hTItem);
	}	
	
	// Scroll Tree control depending on mouse position
	CRect rectClient;
	pWnd->GetClientRect(&rectClient);
	pWnd->ClientToScreen(rectClient);
	pWnd->ClientToScreen(&point);
	int nScrollDir = -1;
	if ( point.y >= rectClient.bottom - RECT_BORDER)
		nScrollDir = SB_LINEDOWN;
	else
	if ( (point.y <= rectClient.top + RECT_BORDER) )
		nScrollDir = SB_LINEUP;

	
	if ( nScrollDir != -1 ) 
	{
		int nScrollPos = pWnd->GetScrollPos(SB_VERT);
		WPARAM wParam = MAKELONG(nScrollDir, nScrollPos);
		pWnd->SendMessage(WM_VSCROLL, wParam);
	}
	
	nScrollDir = -1;
	if ( point.x <= rectClient.left + RECT_BORDER )
		nScrollDir = SB_LINELEFT;
	else
	if ( point.x >= rectClient.right - RECT_BORDER)
		nScrollDir = SB_LINERIGHT;
	
	if ( nScrollDir != -1 ) 
	{
		int nScrollPos = pWnd->GetScrollPos(SB_VERT);
		WPARAM wParam = MAKELONG(nScrollDir, nScrollPos);
		pWnd->SendMessage(WM_HSCROLL, wParam);
	}
	
	return dropeffectRet;
	
	
}

AnswerRe: OLE image drag and drop between Tree controls Pin
Eugen Podsypalnikov5-Mar-10 1:12
Eugen Podsypalnikov5-Mar-10 1:12 
GeneralRe: OLE image drag and drop between Tree controls Pin
RakeshManohar5-Mar-10 1:18
RakeshManohar5-Mar-10 1:18 
GeneralRe: OLE image drag and drop between Tree controls Pin
Eugen Podsypalnikov5-Mar-10 1:29
Eugen Podsypalnikov5-Mar-10 1:29 
GeneralRe: OLE image drag and drop between Tree controls Pin
RakeshManohar5-Mar-10 2:17
RakeshManohar5-Mar-10 2:17 
QuestionCreateProcess failed Pin
john56325-Mar-10 0:39
john56325-Mar-10 0:39 
AnswerRe: CreateProcess failed Pin
Adam Roderick J5-Mar-10 0:50
Adam Roderick J5-Mar-10 0:50 
GeneralRe: CreateProcess failed Pin
john56325-Mar-10 1:19
john56325-Mar-10 1:19 
GeneralRe: CreateProcess failed Pin
Adam Roderick J5-Mar-10 1:28
Adam Roderick J5-Mar-10 1:28 
GeneralRe: CreateProcess failed Pin
CPallini5-Mar-10 1:55
mveCPallini5-Mar-10 1:55 
GeneralRe: CreateProcess failed Pin
ycc8920095-Mar-10 3:43
ycc8920095-Mar-10 3:43 
GeneralRe: CreateProcess failed Pin
CPallini5-Mar-10 5:23
mveCPallini5-Mar-10 5:23 
AnswerRe: CreateProcess failed Pin
Joe Woodbury5-Mar-10 11:25
professionalJoe Woodbury5-Mar-10 11:25 
QuestionGdiplus::Graphics::DrawString and word wrap Pin
sashoalm4-Mar-10 23:36
sashoalm4-Mar-10 23:36 
AnswerRe: Gdiplus::Graphics::DrawString and word wrap Pin
Luc Pattyn5-Mar-10 1:51
sitebuilderLuc Pattyn5-Mar-10 1:51 
GeneralRe: Gdiplus::Graphics::DrawString and word wrap Pin
sashoalm5-Mar-10 6:34
sashoalm5-Mar-10 6:34 
GeneralRe: Gdiplus::Graphics::DrawString and word wrap Pin
Luc Pattyn5-Mar-10 6:41
sitebuilderLuc Pattyn5-Mar-10 6:41 
Questioncommunicate with usb (MTP) device and IOCTL Pin
Tinf73784-Mar-10 21:54
Tinf73784-Mar-10 21:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.