-
February 24th, 2014, 07:50 AM
#1
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?
Important: I use custom-draw-items.
-
February 24th, 2014, 08:09 AM
#2
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.
but the CListCtrl::CreateDragImage does exactly the same.
Victor Nijegorodov
-
February 24th, 2014, 08:59 AM
#3
Re: CListCtrl::CreateDragImage necesarry for dragging?
ok, I did it like described in many examples with:
- CreateDragImage,
- BeginDrag,
- DragEnter,
But no dragimage appears.
Is it because my CListView do no have icons because it is customdraw?
-
February 24th, 2014, 09:18 AM
#4
Re: CListCtrl::CreateDragImage necesarry for dragging?
now, I deleted DrawShowNolock from OnMouseMove.
The result: I drag a black rectangle in the size of an item over the screen.
Is this the image CreateDragImage created for me?
-
February 24th, 2014, 10:19 AM
#5
Re: CListCtrl::CreateDragImage necesarry for dragging?
Originally Posted by Ralf Schneider
...
But no dragimage appears.
Is it because my CListView do no have icons because it is customdraw?
Well, how could CreateDragImage create a "dragged" image for your items if there is no any image for items at all?
Look at https://www.microsoft.com/msj/0898/wicked0898.aspx
It is for tree control but the things are similar!
Victor Nijegorodov
-
February 24th, 2014, 10:48 AM
#6
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.
-
February 24th, 2014, 11:03 AM
#7
Re: CListCtrl::CreateDragImage necesarry for dragging?
Originally Posted by Ralf Schneider
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.
Victor Nijegorodov
-
February 24th, 2014, 11:11 AM
#8
Re: CListCtrl::CreateDragImage necesarry for dragging?
sorry, I missunderstand your answer #5.
But:
CreateDragImage creates an imagelist with one item.
I replaced it with a resource bitmap as described in an example on codeproject.com:
m_pDragImage->Replace(0,&bitmap, &bitmap);
Then I draw this image:
m_pDragImage->Draw(dc,0,...);
But unfortunately my image will also be replaced again...
OK, I will do another approach.
thx.
Ralf
-
February 24th, 2014, 11:16 AM
#9
Re: CListCtrl::CreateDragImage necesarry for dragging?
Why don't you want to set an image list to the list control?
Victor Nijegorodov
-
February 24th, 2014, 11:18 AM
#10
Re: CListCtrl::CreateDragImage necesarry for dragging?
Originally Posted by Ralf Schneider
...
I replaced it with a resource bitmap as described in an example on codeproject.com:
m_pDragImage->Replace(0,&bitmap, &bitmap);
Then I draw this image:
m_pDragImage->Draw(dc,0,...);
Can you provide a link to this "example"?
Victor Nijegorodov
-
February 24th, 2014, 11:57 AM
#11
Re: CListCtrl::CreateDragImage necesarry for dragging?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|