I have a graphical control class, similar to a CListCtrl, and I'm trying to implement drag and drop for it. I've implemented drag and drop for a CListCtrl by creating a CImageList using the CListCtrl's CreateDragImage function, and then Using the CImageList's built in drag and drop functions for animating the dragging.

I'm trying to do something similar with my class (which I'll call CMyClass), but the problem is I don't have a CreateDragImage function that I can call, so I'm trying to create the drag image myself, using WinAPI calls.

I've created some test code, seeing as I'm having problems, which, when the left mouse button is clicked, tries to capture the image of the current object in my list, and then animate it moving across the screen. At the moment, this kind of works, but the image moving across the screen is just a black box which is the same shape as the image I actually want.

There is some test code in the middle which successfully copies the image I want to the clipboard, so that it can be pasted into eg. paintbrush. This suggests to me that the CBitmap is successfully created, and that there's something wrong with the CImageList::Create or CImageList::Add...
void CMyClass::OnLButtonDown(UINT nFlags, CPoint point) 
	CPoint ptCursor = point;
	CRect r = this->GetRect();
	CImageList DragImage;
	CBitmap CurrentDragImage;	
	// Create a DC for the my class
	CDC dc;	
	HDC hdc = ::GetDC(this->hWnd);

	// Create a memory DC
	CDC memDC;

	CSize sz(r.Width(), r.Height());
	CurrentDragImage.CreateCompatibleBitmap(&dc, sz.cx, sz.cy);
	CBitmap * oldbm = memDC.SelectObject(&CurrentDragImage);

	// Copy the graphics we want to drag to the bitmap
	memDC.BitBlt(0, 0, sz.cx, sz.cy, &dc, r.TopLeft().x, r.TopLeft().y, SRCCOPY);
	// ***TEST CODE: This DOES work - it copies the image I want from the screen to the clipboard and can be pasted in pbrush
	::SetClipboardData(CF_BITMAP, (HBITMAP)CurrentDragImage);
	// ***END TEST CODE		
	DragImage.Create(sz.cx, sz.cy, ILC_COLOR32, 0,1);
	DragImage.Add(&CurrentDragImage, RGB(0,0,0));

	DragImage.BeginDrag(0, point);

	DragImage.DragEnter(this->GetParent(), point);

	for (int i=20; i<200; i++)
		CPoint g;
		g.x = i;
		g.y = i;
		// Just to slow it down enough to see it	
		for (int h=0; h<20000; h++);
Does anyone have any ideas why my code isn't working?