我在2000下实现的文件拖拽,主要用
ON_NOTIFY(LVN_BEGINDRAG, IDC_LIST_FILELIST, OnBegindragListFilelist)
ON_WM_MOUSEMOVE()
ON_WM_LBUTTONUP()
这三个消息。在OnBegindragListFilelist中实现缩略图创建。static CBitmap* bm = NULL;
if(bm!=NULL)
delete bm;
bm = CreateDragThumb();
int nRes = m_ilDrag.Add( bm, bm); // 添加到CImageList中m_ilDrag.BeginDrag( 0, CPoint(nOffset, nOffset - 4));
m_ilDrag.DragEnter( GetDesktopWindow(), pNMListView->ptAction);

m_bDragging = TRUE; //we are in a drag and drop operation
SetCapture ();在OnMouseMove中实现:移动。
m_ilDrag.DragMove(pt); //move the drag image to those coordinates可是上述代码在2000中没有问题,到了XP。就是一块黑图。。不知谁知道是怎么回事?谢谢

解决方案 »

  1.   

    bm = CreateDragThumb();这个函数是怎么实现的?我觉得错只能在这里错
      

  2.   

    这个函数没什么问题。CBitmap* CreateDragThumb()
    {
    CRect rect;
    GetWindowRect(swfrect);
    CDC* pDC = GetDC();

    CDC dc;
    dc.CreateDC("DISPLAY",NULL,NULL,NULL);
    CBitmap* bm = new CBitmap();
    bm->CreateCompatibleBitmap( &dc, rect.Width(), rect.Height());
    CDC tdc;
    tdc.CreateCompatibleDC(&dc);
    CBitmap* pOld = tdc.SelectObject(bm);
    tdc.BitBlt(0, 0, rect.Width(),rect.Height(),&dc,rect.left,rect.top,SRCCOPY);
    tdc.DeleteDC();
    ReleaseDC(pDC);
    return bm;
    }
      

  3.   

    我这的XP不是黑屏,m_ilDrag怎么创建的?
      

  4.   

    不是XP是黑屏,是拖动的缩略图是。m_ilDrag.Create( 120, 90, ILC_COLOR24, 0, 1);
      

  5.   

    终于可以揭帖了竟然是另外一个的list资源的share imagelist被构选了。哪位谈谈这是什么原因?而且2000没问题XP有问题。