Sign in to follow this  

Drag-Drop List Boxes with Win32

This topic is 4730 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

In my current project it would be very nice to have a list box control that allows for its elements to be rearranged based on user input. Is it possible to do this by dragging and dropping the new items into the new spot in windows? If not, what would be the best substitute? I am stuck at the idea of using two buttons, "move current up" and "move current down". While it would work, it's not exactly the elegant solution I was hoping for. Any advice? ms

Share this post


Link to post
Share on other sites
Hi!

Yes, it's possible to write a drag and drop listbox. The following messages are used to implement it:

DL_BEGINDRAG
DL_CANCELDRAG
DL_DRAGGING
DL_DROPPED

Search in Google for it or check out the MFC source code. There's one class named CDragListBox, which implements exactly what you want.

The following site could be a help:
http://www.winapi.net/index.php?inhalt=s44

Bye, hunta

Share this post


Link to post
Share on other sites
If you have a standard list box (NOT list control) you can call MakeDragList once to enable dragging of listbox items.

If an items is dragged and dropped onto the listbox the parent receives a RegisterWindowMessage( DRAGLISTMSGSTRING ) value. The lParam carries the DL_xxx params hunta mentioned.

Share this post


Link to post
Share on other sites

This topic is 4730 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this