Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Moving items in CListBox

Posted on 2004-08-18
5
Medium Priority
?
532 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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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 how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

886 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