Solved

Moving items in CListBox

Posted on 2004-08-18
5
514 Views
Last Modified: 2008-02-01
Hello;

I would like to add the ability for a user to drag items arround from within a listbox so they can manually sort/arrange a list.

Like if a CListBox contained 4 file path and locations.

-------------------
c:\file1.jpg
--------------------
c:\file2.jpg
--------------------
c:\file3.jpg
-------------------
c:\file4.jpg
-------------------

So if a user wanted they could grab the third file by mouse and drag it to the top of the list
or where-ever. So they can drag and drop it.

I read about CDragListBox and it seems that it is for moving items from one list box to another. Not moving from one location in listbox to another. But I could be wrong.

Also I have already customized my listbox to recieve files. with the use of message WM_DROP

Any comments are apreciated.
RJ
0
Comment
Question by:RJSoft
  • 3
5 Comments
 
LVL 3

Author Comment

by:RJSoft
ID: 11837819
I wonder if somehow the clipboard would not help somehow?
0
 
LVL 1

Expert Comment

by:2vijay
ID: 11838178
0
 
LVL 3

Author Comment

by:RJSoft
ID: 11840545
Hello 2vijay

This is the correct answer as I stated the question.

But I am wondering if there is any way to maintain the multiple selection.

I have other functions that depend upon the listbox being able to select more than 1 item.

But in order for CDragListBox type listbox to work it can not be multiple select.

Yet I see how in Windows Explorer you can make a multiple selection and drag that selection to some other folder or something.

I am wondering if Explorer is using a CTreeCtrl or something...?

Any suggestions?

RJ

0
 
LVL 14

Accepted Solution

by:
wayside earned 500 total points
ID: 11844454
Check out this example from codeproject: http://www.codeproject.com/listctrl/dragtest.asp

It uses CListCtrl, and lets you select multiple lines and drag them with in the same control.

I don't know if you can do what you want using a list box.

The Windows Explorer uses tree controls and list controls. The equivalent MFC classes would be CTreeCtrl and CListCtrl, or possibly CTreeView and CListView.
0
 
LVL 3

Author Comment

by:RJSoft
ID: 11845871
Great article!

Thanks much wayside.
RJ
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now