If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

CListCtrl::CreateDragImage necesarry for dragging?

Hello,

I want to drag an item of a clistctrl in another window.
In all the examples I found the function CreateDragImage is mentioned.
Do I need it?
What do this function?
Do it do something with the icons of the listview items?

Re: CListCtrl::CreateDragImage necesarry for dragging?

IMHO you do need it to display a "dragged" icon for the item while dragging it.
This is from MSDN article for CTreeCtrl:

Remarks

Call this function to create a dragging bitmap for the given item in a tree view control, create an image list for the bitmap, and add the bitmap to the image list. An application uses the image-list functions to display the image when the item is being dragged.

Re: CListCtrl::CreateDragImage necesarry for dragging?

I do not see where there is a description on how to that when there are no images in the CTreeView.

Don't you read this article?

Here's what a tree view's parent should do in response to a TVN_BEGINDRAG notification:

Call the control's CTreeCtrl::CreateDragImage function to create a temporary image list containing a drag image. The image will be repeatedly erased and redrawn as the cursor is moved to animate the dragging operation.

Call the image list's CImageList::BeginDrag function, followed by CImageList:ragEnter to draw the first drag image.

Capture the mouse to ensure that the control will continue to receive mouse messages if the cursor moves outside the control window.

Note that CreateDragImage will fail if you haven't called CTreeCtrl::SetImageList to assign an image list to the control. The CImageList pointer returned by CreateDragImage refers to a different image list, but the fact remains that if you don't assign the control an image list, you can't ask the control to create an image list for drag imaging either.