HeaderPane
Main
Hide
Share Link
Print

SelTextLength

Returns the length of the selected text in the edit control portion.

C

int WINAPI SftBox_GetSelTextLength(HWND hwndCtl);

C++

int CSftBox::GetSelTextLength() const;

Parameters

hwndCtl

The window handle of the combo box control.

Returns

The return value is the length of the selected text (in characters), not including a terminating '\0' character. 0 is returned if no text is selected. -1 is returned if the combo box is a dropdown list combo box, which does not have an edit control portion.

Comments

The GetSelTextLength function returns the length of the selected text in the edit control portion of a simple or dropdown combo box.

GetSelTextLength can be used to allocate a buffer of sufficient size before retrieving the selected text using GetSelText. The buffer must provide space for one additional character, the terminating '\0' character.

Examples

C View entire sample code

    SftBox_SetDropHighlight(hwndTarget, -1, FALSE);
    if (!IsOver(hwndTarget, lpInfo->hwnd))
        return;                         // dropped somewhere else

    szText[0] = 0;
    if (lpInfo->area == SFTBOX_AREA_EDIT) {
        // The selected text of the edit portion is copied
        if (SftBox_GetSelTextLength(hwndSource) < sizeof(szText) / sizeof(szText[0]))
            SftBox_GetSelText(hwndSource, szText);
    } else {
        // An item of the list is moved
        LONG from = (LONG) lpInfo->UserData;
        if (SftBox_GetTextLength(hwndSource, from, 0) < sizeof(szText) / sizeof(szText[0])) {
            SftBox_GetText(hwndSource, from, 0, szText);
            SftBox_DeleteString(hwndSource, from);
            if (SftBox_GetCount(hwndSource) > 0)

C++ View entire sample code

    target.SetDropHighlight(-1, FALSE);
    if (!IsOver(target, lpInfo->hwnd))
        return;                         // dropped somewhere else

    szText[0] = 0;
    if (lpInfo->area == SFTBOX_AREA_EDIT) {
        // The selected text of the edit portion is copied
        if (source.GetSelTextLength() < sizeof(szText) / sizeof(szText[0]))
            source.GetSelText(szText);
    } else {
        // An item of the list is moved
        LONG from = (LONG) lpInfo->UserData;
        if (source.GetTextLength(from, 0) < sizeof(szText) / sizeof(szText[0])) {
            source.GetText(from, 0, szText);
            source.DeleteString(from);
            if (source.GetCount() > 0)

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


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