Why I can't CreateDragImage in CTreeCtrl?
-
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! -
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!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();
-
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();
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!
-
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!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.