Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Why I can't CreateDragImage in CTreeCtrl?

Why I can't CreateDragImage in CTreeCtrl?

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    white jungle
    wrote on last edited by
    #1

    Hi,All: I create a subclassed treectrl which allow user drag and drop but if the Item is without image (neither normal image nor slected image) ,I can't create the Drag image ,it return NULL always. SetCapture(); Select(hSelItem,TVGN_CARET); m_pDragImageList=CreateDragImage(hSelItem);//Always return NULL,and the paramter is valid always because I add a check statement to avoid NULL HTREEITEM in it works well while item has image. Can any one help me to point where I am wrong ! Thanks a lot Don't look at me in that way!

    R L 2 Replies Last reply
    0
    • W white jungle

      Hi,All: I create a subclassed treectrl which allow user drag and drop but if the Item is without image (neither normal image nor slected image) ,I can't create the Drag image ,it return NULL always. SetCapture(); Select(hSelItem,TVGN_CARET); m_pDragImageList=CreateDragImage(hSelItem);//Always return NULL,and the paramter is valid always because I add a check statement to avoid NULL HTREEITEM in it works well while item has image. Can any one help me to point where I am wrong ! Thanks a lot Don't look at me in that way!

      R Offline
      R Offline
      Rage
      wrote on last edited by
      #2

      white jungle wrote:

      if the Item is without image (neither normal image nor slected image) ,I can't create the Drag image ,it return NULL always.

      :confused: This behavior seems OK to me. If your item does not have any image, which one should be taken as dragimage ? ~RaGE();

      W 1 Reply Last reply
      0
      • R Rage

        white jungle wrote:

        if the Item is without image (neither normal image nor slected image) ,I can't create the Drag image ,it return NULL always.

        :confused: This behavior seems OK to me. If your item does not have any image, which one should be taken as dragimage ? ~RaGE();

        W Offline
        W Offline
        white jungle
        wrote on last edited by
        #3

        But if you drag a item ,the drag image is consist of the image and of course the text. SO I don't think that the only item which include image and text can be drag and drop! And I write some code to createDragimage with item which only has text. but there's some wrong in my code. That is,I can't check if there is a image with the item. for Example: if I retrieve the imagelist of the treectrl and return NULL.Obviously the item do not has a image. But if the the treectrl return a valid imagelist but the item DO not have a image with it.I use fcuntion GetItemImage(hItem,iImage,iSelImage) to check if the item has a image.but the function always return TRUE.even the item is only consist of text,the parameter iImage,iSelImage will be 0.SO I can't judge if the item has a image with it. Can anyone help me for this issue!? Thank you very much! Don't look at me in that way!

        1 Reply Last reply
        0
        • W white jungle

          Hi,All: I create a subclassed treectrl which allow user drag and drop but if the Item is without image (neither normal image nor slected image) ,I can't create the Drag image ,it return NULL always. SetCapture(); Select(hSelItem,TVGN_CARET); m_pDragImageList=CreateDragImage(hSelItem);//Always return NULL,and the paramter is valid always because I add a check statement to avoid NULL HTREEITEM in it works well while item has image. Can any one help me to point where I am wrong ! Thanks a lot Don't look at me in that way!

          L Offline
          L Offline
          Leif Goodwin
          wrote on last edited by
          #4

          You have to cheat. Create the tree control without an image list. Before calling CreateDragImage, assign an image list to the CTreeCtrl, After the CreateDragImage function returns, assign a NULL image list to the tree control. For example: m_tree.SetImageList( &m_imageListTree, TVSIL_NORMAL ); m_pDragImage = m_tree.CreateDragImage(m_hDragTreeNode); m_tree.SetImageList( NULL, TVSIL_NORMAL ); This assumes that you want a tree control WITHOUT images assigned to each item. If you WANT images in the tree control, just call SetImageList when you create the tree control. You might think that it is possible to assign an image list to the tree control, but for each item say specify -1 as the image index i.e. no image. The problem with this is that it displays the item as if there was a blank image, which is not the same thing.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups