How do I drag items between listviews?
How do I drag items between listviews?
Hi all!
I am still having a hard time doing drag and drop. Could anyone please give me an example on how to do drag and drop between two listviews?
I would like to drag an item from one listview and drop it in a position in another listview.
Regards,
Storck
I am still having a hard time doing drag and drop. Could anyone please give me an example on how to do drag and drop between two listviews?
I would like to drag an item from one listview and drop it in a position in another listview.
Regards,
Storck
-
Num3
- PureBasic Expert

- Posts: 2812
- Joined: Fri Apr 25, 2003 4:51 pm
- Location: Portugal, Lisbon
- Contact:
Please go to www.purearea.net and visit the code archive...
There are several snippets that show how to use D'N'D
There are several snippets that show how to use D'N'D
- Psychophanta
- Always Here

- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
Borland C++ Builder? 2 more people i know and me a little bit, 3 years researching with it, with its internals too. It is a fake: it is base-programmed onto Borland Delphi.
Borland developed firstly Delphi Pascal compiler for windows, and uses it a support to develop C++ Builder compiler.
That's the reason because most of tasks are too slow compiled with it.
Besides of continue bugs in each version.
Objectively VC++ is much better.
And objectively PB is much better than VC++.
Borland developed firstly Delphi Pascal compiler for windows, and uses it a support to develop C++ Builder compiler.
That's the reason because most of tasks are too slow compiled with it.
Besides of continue bugs in each version.
Objectively VC++ is much better.
And objectively PB is much better than VC++.
I bought BCB3 back in 1998 when it was still affordable and the standard version was not limited to non commercial use. Things are different today.
I am sure VC++ is a better choice, but it has a rather steep learning curve, in my opinion that is. Also, I'm not sure I want to spend the extra dollars.
I love PureBasic. It's just this drag and drop thing. I can drag items between lists. No problem. I would also like the items to be inserted if dropped on anoter item. Or be able to drag item1 and drop it on item3 to rearrange the list. I have not found any example doing that.
I take it that I have to check what item is at the drop x,y position. But right now I can't get it to work. Anyone with an idea?
Regards,
Storck
I am sure VC++ is a better choice, but it has a rather steep learning curve, in my opinion that is. Also, I'm not sure I want to spend the extra dollars.
I love PureBasic. It's just this drag and drop thing. I can drag items between lists. No problem. I would also like the items to be inserted if dropped on anoter item. Or be able to drag item1 and drop it on item3 to rearrange the list. I have not found any example doing that.
I take it that I have to check what item is at the drop x,y position. But right now I can't get it to work. Anyone with an idea?
Regards,
Storck
I have tried using LVM_HITTEST and LVM_GETITEMRECT but whatever coordinates I thorw at them I still just get index 0 returned.
Please! Anyone?
For me this is the difference between a borland builder 1 Mb app or a PureBasic 50 kB app. I would like to have drag and drop support in the listboxes though. It looks, well more proffesional I guess.
/Storck
- Psychophanta
- Always Here

- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
For LVM_HITTEST, you need the coordinates relative to the Gadget corner.storck wrote:I have tried using LVM_HITTEST and LVM_GETITEMRECT but whatever coordinates I thorw at them I still just get index 0 returned.![]()
Using WindowMouseX() and substracting GadgetX() doesn't work right,
because WindowMouseX() includes the window border, and GadgetX() doesn't
What I use is this:
(get screen coordinates, and map them directly to the gadget coordinates)
Code: Select all
UseWindow(#WINDOW_Preferences)
hittest.LV_HITTESTINFO
hittest\pt\x = WindowMouseX() + WindowX() ; WindowMouseX() includes the border size
hittest\pt\y = WindowMouseY() + WindowY() ; so we first get screen coordinates and map
; them, to the gadget coords
MapWindowPoints_(#NULL, GadgetID(#PrefsDefaultList), @hittest\pt, 1)
CurrentItem = SendMessage_(GadgetID(#PrefsDefaultList), #LVM_HITTEST, 0, @hittest) quidquid Latine dictum sit altum videtur


