OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
About the Drag List Control

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

  1. #include <owl/draglist.h> for declarations of TDragList and TDragListEventHandler classes.
  2. 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);
  3. Construct the control.
    DragList = new TExampleDragList(this, DragListId, x, y, x + 200, y + 100);
  4. 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_RESPONSE_TABLE2(TDragListParentWindow, TWindow, TDragListEventHandler)
    #define END_RESPONSE_TABLE
    Definition eventhan.h:466
    #define DEFINE_RESPONSE_TABLE2(cls, base1, base2)
    Macro to define a response table for a class with two bases.
    Definition eventhan.h:506
  5. As you would any listbox, add items to the drag list box after
    TDragList::SetupWindow() has been called.
    DragList->AddString("Soyeun");
    DragList->AddString("Valerie");
  6. The virtual functions will be called at the proper time whenever the user does something. For example:
    BeginDrag()
    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.