HeaderPane
Main
Hide
Share Link
Print

TextLength

Returns the length of an item's cell text.

C

int WINAPI SftBox_GetTextLength(HWND hwndCtl, LONG indexTC, int col);

C++

int CSftBox::GetTextLength(LONG indexTC, int col) const;

Parameters

hwndCtl

The window handle of the combo box control.

indexTC

The zero-based index number of the item for which the text length is to be retrieved. Specify -1 to retrieve the text length of the currently selected item (see GetCurSel).

col

The zero-based column number whose text length is to be retrieved.

Returns

The return value is the length of the item's cell text in the specified column, not including the terminating '\0', or -1 if an error occurred (for example, if col is not a valid column number, or indexTC is -1 and no item is selected).

Comments

The GetTextLength function returns the length of an item's cell text.

GetTextLength can be used to determine the size of the buffer needed to retrieve the cell text using GetText. The buffer must have room for the terminating '\0'.

SftBox_GetLBTextLength is an alternate name for the C function SftBox_GetTextLength. They can be used interchangeably.

Examples

C View entire sample code

    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)
                SftBox_SetCurSel(hwndSource, min(from, SftBox_GetCount(hwndSource) - 1));
        }
    }
    if (!szText[0])

C++ View entire sample code

    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)
                source.SetCurSel(min(from, source.GetCount() - 1));
        }
    }
    if (!szText[0])

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


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