Solved

Moving items in CListBox

Posted on 2004-08-18
5
520 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

920 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

19 Experts available now in Live!

Get 1:1 Help Now