How do I drag items between listviews?

Everything else that doesn't fall into one of the other PB categories.
storck
User
User
Posts: 83
Joined: Sat Oct 18, 2003 4:56 pm
Location: Sweden

How do I drag items between listviews?

Post by storck »

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
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Please go to www.purearea.net and visit the code archive...

There are several snippets that show how to use D'N'D
storck
User
User
Posts: 83
Joined: Sat Oct 18, 2003 4:56 pm
Location: Sweden

Post by storck »

Thank you! :D

I was beginning to think that I had to go back to Borland C++ Builder becaus of this. That would not have been nice since my project was 80% completed.

Regards,

Storck

May the source be with you all...
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

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++. :D
storck
User
User
Posts: 83
Joined: Sat Oct 18, 2003 4:56 pm
Location: Sweden

Post by storck »

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
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

There's a new feature that will come in the new buggy version of Visual Designer 3.81 that does exactly what you want!

If it's done there it means it's also possible for you to make it!
Fred
Administrator
Administrator
Posts: 18350
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Num3 wrote:There's a new feature that will come in the new buggy version of Visual Designer 3.81 that does exactly what you want!
Watch your back, I hear Berikco coming quickly... :wink:
storck
User
User
Posts: 83
Joined: Sat Oct 18, 2003 4:56 pm
Location: Sweden

Post by storck »

I have (almost) solved the problem. There is nothing like Win32.hlp. :P Anyways, thank you all for being so supportive. That is one of the thing I love with PureBasic.

C ya!

/Storck
storck
User
User
Posts: 83
Joined: Sat Oct 18, 2003 4:56 pm
Location: Sweden

Post by storck »

:cry: I am lost. I can drag items in or between list views. I can also get the coordinates from the drop point. What I can't do is to convert the coordinates to the item index in the list.

I have tried using LVM_HITTEST and LVM_GETITEMRECT but whatever coordinates I thorw at them I still just get index 0 returned. :evil:

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
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

Welcome to the wonderful and incoherent Microsoft WinAPI world :P
storck
User
User
Posts: 83
Joined: Sat Oct 18, 2003 4:56 pm
Location: Sweden

Post by storck »

Thank you! :wink:
Doobrey
Enthusiast
Enthusiast
Posts: 218
Joined: Sat Apr 26, 2003 4:47 am
Location: Dullsville..population: me
Contact:

Post by Doobrey »

Don`t forget that once you get it working, MS will bring out a new version of Windows and break your app.. :roll:
freak
PureBasic Team
PureBasic Team
Posts: 5947
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

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. :evil:
For LVM_HITTEST, you need the coordinates relative to the Gadget corner.
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)          
Timo
quidquid Latine dictum sit altum videtur
storck
User
User
Posts: 83
Joined: Sat Oct 18, 2003 4:56 pm
Location: Sweden

Post by storck »

Thank you freak! I will try it out. :P

/Storck
freak
PureBasic Team
PureBasic Team
Posts: 5947
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

I wrote a little somthing about that today. See here:
viewtopic.php?p=41351#41351

Timo
quidquid Latine dictum sit altum videtur
Post Reply