CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11
  1. #1
    Join Date
    Jul 2001
    Posts
    306

    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.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    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

  3. #3
    Join Date
    Jul 2001
    Posts
    306

    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?

  4. #4
    Join Date
    Jul 2001
    Posts
    306

    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?

  5. #5
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    Re: CListCtrl::CreateDragImage necesarry for dragging?

    Quote Originally Posted by Ralf Schneider View Post
    ...
    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

  6. #6
    Join Date
    Jul 2001
    Posts
    306

    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.

  7. #7
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    Re: CListCtrl::CreateDragImage necesarry for dragging?

    Quote Originally Posted by Ralf Schneider View Post
    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:
    1. 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.
    2. Call the image list's CImageList::BeginDrag function, followed by CImageList:ragEnter to draw the first drag image.
    3. 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

  8. #8
    Join Date
    Jul 2001
    Posts
    306

    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

  9. #9
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    Re: CListCtrl::CreateDragImage necesarry for dragging?

    Why don't you want to set an image list to the list control?
    Victor Nijegorodov

  10. #10
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,395

    Re: CListCtrl::CreateDragImage necesarry for dragging?

    Quote Originally Posted by Ralf Schneider View Post
    ...
    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

  11. #11
    Join Date
    Jul 2001
    Posts
    306

    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
  •  





Click Here to Expand Forum to Full Width

Featured