SDI 左右两个视图,均为TreeView,从右边向左视图拖拉,右边好好的,到左边不能显示拖拉的图像.代码如下,谢谢各位,问题解决给分. //右视图开始拖拉的
void CClientView::OnBegindrag(NMHDR* pNMHDR, LRESULT* pResult)
{
CTreeCtrl& tree = GetTreeCtrl()
m_bDraggingNow = TRUE;
m_hDraggedItem = pNMTreeView->itemNew.hItem;//保存变量
tree.Select(m_hDraggedItem, TVGN_CARET);
m_pDragImageList = tree.CreateDragImage(m_hDraggedItem);
m_pDragImageList->DragEnter(&tree, pNMTreeView->ptDrag);
m_pDragImageList->BeginDrag(0, CPoint(10, 10));
}
//右视图鼠标拖动消息
void CClientView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if (m_bDraggingNow)
{
CTreeCtrl& tree = GetTreeCtrl();
m_pDragImageList->DragEnter(&tree, point);
m_pDragImageList->DragMove(point);
}
CTreeView::OnMouseMove(nFlags, point);
}
//左视图
void CLeftView::OnMouseMove(UINT nFlags, CPoint point)
{
CClientView *pRight=((CMainFrame*)AfxGetMainWnd())->pRightView;
CRect ClientRect;
if(!pRight->m_bDraggingNow)
return;
else
{
//pRight->GetTreeCtrl().;
//this->GetClientRect()
GetTreeCtrl().Select(pRight->m_hDraggedItem,TVGN_DROPHILITE);
this->GetClientRect(&ClientRect);
pRight->m_pDragImageList->DragEnter(&GetTreeCtrl(),point);
point.x=point.x-(ClientRect.right-ClientRect.left);
pRight->m_pDragImageList->DragMove(point);
//pRight->m_pDragImageList->DragShowNolock(true);
}
CTreeView::OnMouseMove(nFlags, point);
}
void CClientView::OnBegindrag(NMHDR* pNMHDR, LRESULT* pResult)
{
CTreeCtrl& tree = GetTreeCtrl()
m_bDraggingNow = TRUE;
m_hDraggedItem = pNMTreeView->itemNew.hItem;//保存变量
tree.Select(m_hDraggedItem, TVGN_CARET);
m_pDragImageList = tree.CreateDragImage(m_hDraggedItem);
m_pDragImageList->DragEnter(&tree, pNMTreeView->ptDrag);
m_pDragImageList->BeginDrag(0, CPoint(10, 10));
}
//右视图鼠标拖动消息
void CClientView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if (m_bDraggingNow)
{
CTreeCtrl& tree = GetTreeCtrl();
m_pDragImageList->DragEnter(&tree, point);
m_pDragImageList->DragMove(point);
}
CTreeView::OnMouseMove(nFlags, point);
}
//左视图
void CLeftView::OnMouseMove(UINT nFlags, CPoint point)
{
CClientView *pRight=((CMainFrame*)AfxGetMainWnd())->pRightView;
CRect ClientRect;
if(!pRight->m_bDraggingNow)
return;
else
{
//pRight->GetTreeCtrl().;
//this->GetClientRect()
GetTreeCtrl().Select(pRight->m_hDraggedItem,TVGN_DROPHILITE);
this->GetClientRect(&ClientRect);
pRight->m_pDragImageList->DragEnter(&GetTreeCtrl(),point);
point.x=point.x-(ClientRect.right-ClientRect.left);
pRight->m_pDragImageList->DragMove(point);
//pRight->m_pDragImageList->DragShowNolock(true);
}
CTreeView::OnMouseMove(nFlags, point);
}
{
CClientView *pRight=((CMainFrame*)AfxGetMainWnd())->pRightView;
CRect ClientRect;
if(!pRight->m_bDraggingNow)
return;
else
{
//pRight->GetTreeCtrl().;
//this->GetClientRect()
GetTreeCtrl().Select(pRight->m_hDraggedItem,TVGN_DROPHILITE);
this->GetClientRect(&ClientRect);
pRight->m_pDragImageList->DragEnter(&GetTreeCtrl(),point);////失败啊,有什么解决办法?
point.x=point.x-(ClientRect.right-ClientRect.left);
pRight->m_pDragImageList->DragMove(point);
//pRight->m_pDragImageList->DragShowNolock(true);
}
CTreeView::OnMouseMove(nFlags, point);
}