Hide

SftTree/DLL 7.5 - Tree Control

Display
Print

SFTTREE_DRAGINFO Structure

The SFTTREE_DRAGINFO structure is used during drag & drop operations and can be retrieved using GetDragInfo.

typedef struct tagSftTreeDragInfo {

    /* read/only fields */
    POINT ptDrag;                       // screen coordinate of mouse cursor
    HWND hwnd;                          // window under mouse cursor
    int index;                          // current drop entry, -1 if dropped
                                        // outside of tree
    BOOL fMultiple;                     // moving/copying more than one item
    BOOL fControl;                      // TRUE if control key pressed
    BOOL fShift;                        // TRUE if shift key pressed
    int button;                         // button used for dragging
#define SFTTREE_LBUTTON    1
#define SFTTREE_MBUTTON    2
#define SFTTREE_RBUTTON    3

    /* fields set by application: */
    BOOL fDropOK;                       // set to FALSE if drop not possible
    HCURSOR hCursor;                    // application-defined cursor (drag)

    BOOL fLeftTree;                     // True if left side tree control is drag source

} SFTTREE_DRAGINFO, * LPSFTTREE_DRAGINFO;

Members

ptDrag

Not modifiable. The current screen coordinates of the mouse cursor.

hwnd

Not modifiable. The handle of the window under the mouse cursor.

index

Not modifiable. Current entry where items could be dropped.

This field may be -1 if the items will be dropped outside the tree control (even in another tree control).

fMultiple

Not modifiable. TRUE if more than one item is being dragged, otherwise FALSE.

fControl

Not modifiable. TRUE if the Control key is pressed, otherwise FALSE.

fShift

Not modifiable. TRUE if the Shift key is pressed, otherwise FALSE.

button

One of the values SFTTREE_LBUTTON, SFTTREE_MBUTTON or SFTTREE_RBUTTON indicating which button is used for the operation.

fDropOK

Modifiable. An application can set this to TRUE or FALSE to indicate dropping is currently not possible while processing a SFTTREEN_BEGINDRAG or SFTTREEN_DRAGGING notification. fDropOK has no effect on how SftTree/DLL handles the drag & drop. The field is for use by the application only and is preserved between all drag & drop events.

hCursor

An application can set the desired mouse cursor while processing a SFTTREEN_BEGINDRAG or SFTTREEN_DRAGGING notification. By default, SftTree/DLL will set a "don't-drop" cursor if dragging outside the current tree control and a simple drop cursor inside the tree control. Implementation of a copy/move cursor based on the number of items or the Control or Shift keys is up to the application.

fLeftTree

In a split tree control, fLeftTree is set to TRUE if the drag & drop operation started in the left pane, otherwise it is set to FALSE.

Comments

The SFTTREE_DRAGINFO structure is used during drag & drop operations and can be retrieved using GetDragInfo.

To find out more about the current drag & drop operation, an application can use GetDragInfo, which makes a pointer to the SFTTREE_DRAGINFO structure available. This area is only valid while processing one WM_COMMAND notification and must be retrieved for each notification. Some of the SFTTREE_DRAGINFO members are modifiable. GetDragInfo should be used when processing SFTTREEN_BEGINDRAG, SFTTREEN_DRAGGING, SFTTREEN_ENDDRAG or SFTTREEN_CANCELDRAG notifications.

A tree control must be defined using the SFTTREESTYLE_DRAGDROP window style to support drag & drop.

Examples

C

/**********************************************************************/
/*                      Left Tree Control Handling                    */
/**********************************************************************/

static void DraggingLeft()
{
    /* Drag & drop in progress, which was started on the left side tree */
    LPSFTTREE_DRAGINFO lpInfo;
    lpInfo = SftTree_GetDragInfo(m_hwndLeftTree);

    if (lpInfo->hwnd != m_hwndLeftTree) { // The target is another window

        // clear old drop target
        if (m_hwndLastTarget) {
            SftTree_SetDropHighlight(m_hwndLastTarget, -1, FALSE);
            SftTree_StopAutoExpandTimer(m_hwndLastTarget);

C++

    m_LeftTree.Expand(index, TRUE, FALSE);
}

void CSampleDlg::OnEndDragLeft()
{
    /* The user dropped something */

    LPSFTTREE_DRAGINFO lpInfo;
    int index;
    CString str, text;

    lpInfo = m_LeftTree.GetDragInfo();

    if (lpInfo->hwnd != m_LeftTree.m_hWnd) { // The target is another window

        // In this example the "other" control could be the right tree control

See Also C/C++ API | Categories | Notifications