HeaderPane
Main
Hide
Share Link
Print

DropHighlight

Defines the current drag & drop target location.

C

LONG WINAPI SftBox_GetDropHighlight(HWND hwndCtl);
int WINAPI SftBox_SetDropHighlight(HWND hwndCtl, LONG indexTC, BOOL fScroll);

C++

LONG CSftBox::GetDropHighlight() const;
int CSftBox::SetDropHighlight(LONG indexTC, BOOL fScroll);

Parameters

hwndCtl

The window handle of the combo box control.

indexTC

The zero-based index of the item which is the new drop target or -1 to clear the current drop target. If SetDropHighlightStyle is set to SFTBOX_DROPHIGHLIGHT_BETWEEN, indexTC can be set to the index of the last item +1, which causes the drop target to be displayed beyond the last item.

fScroll

Set to TRUE to define that items should be scrolled vertically if the drop target indexTC is the first or last item currently displayed in the dropdown portion. Set to FALSE to suppress vertical scrolling.

Returns

GetDropHighlight returns the current drop target or -1 if no drop target has been defined.

SetDropHighlight returns 0 if the function was successful, otherwise -1 is returned.

Comments

The GetDropHighlight and SetDropHighlight functions define the current drag & drop target location.

SetDropHighlight is used to highlight an item in the dropdown portion of the combo box control as the target of a drag & drop operation. There can be only one drop target at any one time. By calling SetDropHighlight with a new item index, the previous item is no longer a drop target and is no longer highlighted.

SetDropHighlightStyle can be used to control the appearance of the target item. Depending on the SetDropHighlightStyle settings, the index specified is the actual drop target or the insertion point. If used as an insertion point, the index value can be set to the number of items in the combo box control, which moves the insertion point to the end of the list of items.

By setting SetDropHighlight to -1, the current drop target is cleared.

It is the application's responsibility to visually implement a drag & drop operation (see SetDragType). When the target of the operation is a combo box control, this is accomplished by using CalcIndexFromPoint and SetDropHighlight with the target combo box control while processing SFTBOXN_DRAGGING notifications. If dragging to another control type (list box, edit control, etc.), other means may have to be used as implemented by the target control.

Once a drag & drop operation ends, SetDropHighlight should be called to clear the drop target by setting indexTC to -1. This removes the highlight indicator from the target item.

If SetDropHighlight is set to the first (or last) item currently visible in the dropdown portion, the items automatically scroll up (or down) by one item if fScroll is TRUE. This allows a user to drag items to a target item which has to be scrolled into view first. The items will scroll in the given direction until SetDropHighlight is called with indexTC set to -1 or with indexTC set to an item which is not the first (or last) item visible.

Examples

C View entire sample code

    if (IsOver(hwndTarget, lpInfo->hwnd)) {
        // Over the other combo box, show where the item will be inserted
        POINT pt = lpInfo->ptDrag;
        BOOL fMain;
        LONG index;
        ScreenToClient(hwndTarget, &pt);
        index = SftBox_CalcIndexFromPoint(hwndTarget, &pt, &fMain);
        SftBox_SetDropHighlight(hwndTarget, fMain ? -1 : index, TRUE);
        lpInfo->hCursor = LoadCursor(g_hInst, MAKEINTRESOURCE(IDC_DRAG));
    } else {
        SftBox_SetDropHighlight(hwndTarget, -1, FALSE);
        lpInfo->hCursor = LoadCursor(NULL, IDC_NO);
    }
}

static void OnEndDrag(HWND hwndSource)

C++ View entire sample code

    LPSFTBOX_DRAGINFO lpInfo = source.GetDragInfo();

    if (IsOver(target, lpInfo->hwnd)) {
        // Over the other combo box, show where the item will be inserted
        CPoint pt = lpInfo->ptDrag;
        BOOL fMain;
        target.ScreenToClient(&pt);
        LONG index = target.CalcIndexFromPoint(&pt, &fMain);
        target.SetDropHighlight(fMain ? -1 : index, TRUE);
        lpInfo->hCursor = AfxGetApp()->LoadCursor(IDC_DRAG);
    } else {
        target.SetDropHighlight(-1, FALSE);
        lpInfo->hCursor = AfxGetApp()->LoadStandardCursor(IDC_NO);
    }
}

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


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