drag drop in listview

Started by Fred Tomke, March 25, 2010, 03:38:23 PM

Previous topic - Next topic

Fred Tomke

Hello,

I attached a small sample. It is the goal to setup a description.
When the checkbox if off, you can add or remove properties from the description by double clicking the desired items from the left list or the not desired items from the right list.
Unfortunately, double click does not work when AllowDrag is set. I hope there would be any chance to make it work again.

When the checkbox is set, the desired property can be moved from the left list to the right. The preview shall be updated automatically. That's why OnDragnDropFromControl is active.
Removing and adding properties work properly using Drag&Drop.
But changing the order within the right list does not work properly: after finishing the event OnDragnDropFromControl OpenDCL removes the moved item. I would agree this if the moved item would appear at the destination. But it does not so.

How can I solve this?

Thanks for testing.
Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

owenwengerd

Quote from: Fred Tomke on March 25, 2010, 03:38:23 PM
But changing the order within the right list does not work properly: after finishing the event OnDragnDropFromControl OpenDCL removes the moved item. I would agree this if the moved item would appear at the destination. But it does not so.

Your OnDragnDropFromControl must insert the item being dropped. It looks like your code is completely replacing the entire list during the handler, which means the drop handler is erasing the source item. Try simplifying your code so that it only inserts the dropped item and nothing else; it should then work as you expect.

owenwengerd

The problem with being unable to double click when drag is enabled is due to an odd design of the MFC drag/drop implementation. I have now written a custom implementation for the next build that fixes the problem. I am concerned that there may be a very good reason for the MFC behavior, but in my brief testing, my custom code seems to be working fine, so we will see.

Fred Tomke

Quote from: owenwengerd on March 25, 2010, 06:28:23 PM
Try simplifying your code so that it only inserts the dropped item and nothing else; it should then work as you expect.

Yes I tried and sometimes it will remove the DropItem.
I attached a new sample.

Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

owenwengerd

You are correct, it is removing the wrong item after the new item is inserted before the source item. I have fixed this now for the next build.

Fred Tomke

Great, thank you.
Have a nice weekend!

Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]