Jump to content
  • Advertisement
Sign in to follow this  
tneva82

[Windows] Drag & Drop with list view.

This topic is 3343 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Me again bothering everybody with stupid questions. Anyway list view drag & drop is almost working. Just one tiny weeny little problem. When following 2 lines are executed image of drag dissapears if it is over items in list view. Outside list view or inside list view but not over items it works just fine. It's as if it would be drawn _behind_ the listview items. Why would it work like that when with treeview it works just fine?
	ListView_SetItemState(hwndList, -1, LVIS_DROPHILITED, LVIS_DROPHILITED); 
	ListView_SetItemState(hwndList, -1, 0, LVIS_DROPHILITED);


Purpose of above code is to first select every item as highlight drop target and then deselect them. If I don't do this then it will keep selecting items which is not right at all(there's supposed to be just one target for drop afterall). Full code is:
    ImageList_DragMove(Pos.x, Pos.y+35); 


    ImageList_DragShowNolock(FALSE);

	lvht.pt.x = LOWORD(lParam);
    lvht.pt.y = HIWORD(lParam);
    ClientToScreen(hWndMain, &lvht.pt);
    ScreenToClient(hwndList, &lvht.pt);


	int result=(int)SendMessage(hwndList,LVM_HITTEST,0, (LPARAM)&lvht);

	ListView_SetItemState(hwndList, -1, LVIS_DROPHILITED, LVIS_DROPHILITED); 
	ListView_SetItemState(hwndList, -1, 0, LVIS_DROPHILITED);
	
	if(result!=-1) {             // if there is a hit	
		ListView_SetItemState(hwndList, result, LVIS_DROPHILITED, LVIS_DROPHILITED);

	} 
	 
	ImageList_DragShowNolock(TRUE);


Why would selecting and deselecting other items make image dissapear if there is item under it? Would there be better way to show target of drop operation? With treeview simple SendMessage(hwndTree,TVM_SELECTITEM,TVGN_DROPHILITE, (LPARAM)hitTarget); takes care of that but there's no LVM_SELECTITEM message as far as I can see. [Edited by - tneva82 on October 15, 2009 6:39:25 AM]

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!