Solved

Moving items in CListBox

Posted on 2004-08-18
5
526 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
White board coding practice 3 98
Beginner to Unreal Engine 4 5 119
Installshield for Embarcadero EX 10.1 Berlin 4 92
using interface in TLB 3 29
When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
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…
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.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

739 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