HeaderPane
Main
Hide
Share Link
Print

SFTBOX_DRAGINFO Structure

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

typedef struct tagSftBoxDragInfo {
    /* read/only fields */
    HWND hwnd;                              // window under mouse cursor
    POINT ptDrag;                           // screen coordinate of mouse cursor
    LONG index;                             // current drop entry, -1 if none
    BOOL fControl;                          // TRUE if control key pressed
    BOOL fShift;                            // TRUE if shift key pressed
    int area;                               // area starting drag & drop
#define SFTBOX_AREA_STATIC   1              // static portion
#define SFTBOX_AREA_EDIT     2              // edit control portion
#define SFTBOX_AREA_DROPDOWN 3              // dropdown portion
    int button;                             // button used for dragging
#define SFTBOX_LBUTTON    1
#define SFTBOX_MBUTTON    2
#define SFTBOX_RBUTTON    3
    /* fields set by application: */
    BOOL fAbort;                            // set to TRUE to abort drag & drop
    HCURSOR hCursor;                        // application sets cursor (drag)
    SFTBOX_DWORD_PTR UserData;              // user data, preserved between events
    SFTBOX_DWORD_PTR res1, res2, res3, res4;
    short res1s, res2s, res3s, res4s;
} SFTBOX_DRAGINFO, * LPSFTBOX_DRAGINFO;

Members

hwnd

Not modifiable. The handle of the window under the mouse cursor. A combo box control consists of several windows, so this handle can be the handle of a child window of a combo box control.

ptDrag

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

index

Not modifiable. If the drag & drop operation was started in the dropdown portion, index contains the zero-based index of the item in the dropdown portion where items could be dropped, or -1 if the mouse cursor is outside of the dropdown portion. If the drop highlight style SFTBOX_DROPHIGHLIGHT_BETWEEN is used (see SetDropHighlightStyle), index is equal to the number of items (see GetCount) while the mouse cursor is below the last item. If the drag & drop operation was started in the edit control portion, index contains the index of the currently selected item (see GetCurSel) or -1.

fControl

Not modifiable. A nonzero value if the Control key is pressed, otherwise 0.

fShift

Not modifiable. A nonzero value if the Shift key is pressed, otherwise 0.

area

Not modifiable. Describes where the drag & drop operation was started.

areaDescription
SFTBOX_AREA_STATICNot used. Drag & drop operations cannot be started in the static portion.
SFTBOX_AREA_EDITThe drag & drop operation was started in the edit control portion, by dragging the selected text.
SFTBOX_AREA_DROPDOWNThe drag & drop operation was started in the dropdown portion, by dragging an item.

button

Not modifiable. One of the values SFTBOX_LBUTTON, SFTBOX_MBUTTON or SFTBOX_RBUTTON indicating which mouse button is used for the operation. A drag & drop operation started in the edit control portion always uses the left mouse button.

fAbort

Modifiable. An application can set this member to TRUE while processing the SFTBOXN_BEGINDRAG notification to abort the drag & drop operation. The operation ends immediately and no SFTBOXN_CANCELDRAG notification is sent. If the drag & drop operation was started in the edit control portion, an application can also set this member to TRUE while processing a SFTBOXN_DRAGGING notification, which ends the operation with a SFTBOXN_CANCELDRAG notification. The combo box control resets this member to FALSE before each notification.

hCursor

Modifiable. An application can set the desired mouse cursor while processing a SFTBOXN_BEGINDRAG or SFTBOXN_DRAGGING notification. The combo box control provides a default cursor before each notification. Implementation of a copy/move cursor based on the Control or Shift keys or the current drop target is up to the application.

UserData

Modifiable. An application-defined value. This member is for use by the application only and is preserved between all drag & drop notifications.

res1, res2, res3, res4, res1s, res2s, res3s, res4s

Reserved. h1 Comments

To find out more about the current drag & drop operation, an application can use GetDragInfo, which makes a pointer to the SFTBOX_DRAGINFO structure available. The contents are only valid while processing one notification and must be retrieved for each notification. GetDragInfo should be used when processing SFTBOXN_BEGINDRAG, SFTBOXN_DRAGGING, SFTBOXN_ENDDRAG or SFTBOXN_CANCELDRAG notifications.

Drag & drop must be enabled using SetDragType. Depending on the drag type, drag & drop operations can be started in the edit control portion, the dropdown portion or both.

The combo box control does not move or copy any data when a drag & drop operation ends. The application is responsible for the desired action when processing the SFTBOXN_ENDDRAG notification.

Pointer typedef: LPSFTBOX_DRAGINFO is a pointer to a SFTBOX_DRAGINFO structure.

Examples

C View entire sample code

static BOOL IsOver(HWND hwndBox, HWND hwndPoint)
{
    // A combo box consists of several windows
    return hwndPoint && (hwndPoint == hwndBox || IsChild(hwndBox, hwndPoint));
}

static void OnBeginDrag(HWND hwndSource)
{
    LPSFTBOX_DRAGINFO lpInfo = SftBox_GetDragInfo(hwndSource);

    // Remember the item being dragged. The user data is preserved
    // until the drag and drop operation ends.
    lpInfo->UserData = (SFTBOX_DWORD_PTR) SftBox_GetCurSel(hwndSource);
    if (lpInfo->area == SFTBOX_AREA_DROPDOWN && (LONG) lpInfo->UserData < 0)
        lpInfo->fAbort = TRUE;          // nothing to drag
}

C++ View entire sample code

static BOOL IsOver(const CSftBox& box, HWND hwndPoint)
{
    // A combo box consists of several windows
    return hwndPoint && (hwndPoint == box.m_hWnd || ::IsChild(box.m_hWnd, hwndPoint));
}

void CMainDlg::BeginDrag(CSftBox& source)
{
    LPSFTBOX_DRAGINFO lpInfo = source.GetDragInfo();

    // Remember the item being dragged. The user data is preserved
    // until the drag and drop operation ends.
    lpInfo->UserData = (SFTBOX_DWORD_PTR) source.GetCurSel();
    if (lpInfo->area == SFTBOX_AREA_DROPDOWN && (LONG) lpInfo->UserData < 0)
        lpInfo->fAbort = TRUE;          // nothing to drag
}

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


Last Updated 11/21/2026 - (email)
© 2026 Softel vdm, Inc.