代码如下:
void CEMap_TreeCtrl::OnLButtonUp(UINT nFlags, CPoint point) 
{
         if (Dragging) 
            {
                ImageList_DragLeave(this->m_hWnd);
                ImageList_EndDrag();  //Ends a drag operation
                ReleaseCapture();
                ShowCursor(TRUE);  //The ShowCursor function displays or hides the cursor
                Dragging = FALSE;
                ClipCursor(NULL);
            }
CTreeCtrl::OnLButtonUp(nFlags, point);
}void CEMap_TreeCtrl::OnMouseMove(UINT nFlags, CPoint point) 
{
if (Dragging) 

ClientToScreen(&point);
Pos = MAKEPOINTS(point);
ImageList_DragMove(Pos.x , Pos.y );
ImageList_DragShowNolock(FALSE);
tvht.pt.x = Pos.x -16 ; 
tvht.pt.y = Pos.y -16 ; 
if(hitTarget=(HTREEITEM)SendMessage(TVM_HITTEST,NULL,(LPARAM)&tvht)) // if there is a hit
SendMessage(TVM_SELECTITEM,TVGN_DROPHILITE,(LPARAM)hitTarget);   // highlight it
ImageList_DragShowNolock(TRUE); 

CTreeCtrl::OnMouseMove(nFlags, point);
}void CEMap_TreeCtrl::OnBegindrag(NMHDR* pNMHDR, LRESULT* pResult) 
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
if(pNMTreeView == NULL)
return; ClientToScreen(&pNMTreeView->ptDrag);
HIMAGELIST hImg;
hImg=TreeView_CreateDragImage(this->m_hWnd, pNMTreeView->itemNew.hItem);
ImageList_BeginDrag(hImg, 0, 0, 0);
CWnd *cwnd = GetParent();
HWND hwnd = cwnd->GetSafeHwnd();
RECT   rect;//将光标定义在视图区内   
cwnd->GetWindowRect(&rect);   
ClipCursor(&rect); 
ImageList_DragEnter(hwnd,pNMTreeView->ptDrag.x ,pNMTreeView->ptDrag.y);
ShowCursor(FALSE); 
SetCapture(); 
Dragging = TRUE;
*pResult = 0;
}