Ending the Drag Operation

The following function ends the drag operation and draws the image in its final location. It also releases the mouse capture.

// StopDragging - ends a drag operation and draws the image

// at its final location.

// Returns TRUE if successful or FALSE otherwise.

// hwnd - handle of the window in which the bitmap is dragged

// himl - handle of the image list

// ptCur - coordinates of the cursor

//

// Global variable

// g_ptHotSpot - location of the image's hot spot

extern POINT g_ptHotSpot;

BOOL StopDragging(HWND hwnd, HIMAGELIST himl, POINT ptCur)

{

ImageList_EndDrag();

ImageList_DragLeave(hwnd)

g_fDragging = FALSE;

DrawTheImage(hwnd, himl, ptCur.x - g_ptHotSpot.x,

ptCur.y - g_ptHotSpot.y);

ReleaseCapture();

return TRUE;

}