The TDragList class creates an augmented list box that lets the user rearrange items with a mouse.
It is best used for displaying a list of items that the user can reorder.
A major advantage this control has over the listbox is the support for multiple columns. The right pane of the Windows 95 Explorer uses this type of window. The native control for Windows 95 is the Drag List Box common control.
Using the Drag List Control
- #include <owl/draglist.h> for declarations of TDragList and TDragListEventHandler classes.
- Derive a class from TDragList and override any of the following virtual functions:
virtual bool BeginDrag(
int item,
const TPoint&
point);
virtual TCursorType Dragging(
int item,
const TPoint&
point);
virtual void Dropped(
int item,
const TPoint&
point);
virtual void CancelDrag(
int item,
const TPoint&
point);
- Construct the control.
- In the parent window class that uses the drag list as a child, mix-in the TDragListEventHandler class and add it as a base for the response table.
#define END_RESPONSE_TABLE
#define DEFINE_RESPONSE_TABLE2(cls, base1, base2)
Macro to define a response table for a class with two bases.
- As you would any listbox, add items to the drag list box after
- The virtual functions will be called at the proper time whenever the user does something. For example: will be called when the user clicks the left mouse button on an item to begin the drag transaction. When the user moves the mouse, the Dragging function will be called. The return type for dragging is an enum that specifies what cursor should be displayed. The Dropped function will be called when the user finishes a drag transaction by releasing the left mouse button. Each of the virtual functions is passed the item index the user wants to drag.