HeaderPane
Main
Hide
Share Link
Print

Text

Defines an item's cell text.

C

int WINAPI SftBox_GetText(HWND hwndCtl, LONG indexTC, int col, LPTSTR lpszBuffer);
BOOL WINAPI SftBox_SetText(HWND hwndCtl, LONG indexTC, int col, LPCTSTR lpszText);

C++

int CSftBox::GetText(LONG indexTC, int col, LPTSTR lpszBuffer) const;
BOOL CSftBox::SetText(LONG indexTC, int col, LPCTSTR lpszText);

Parameters

hwndCtl

The window handle of the combo box control.

indexTC

The zero-based index number of the item for which text information is to be retrieved or set. GetText accepts -1 to retrieve the text of the currently selected item (see GetCurSel).

col

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

lpszBuffer

A pointer to a buffer where the item's cell text will be returned.

lpszText

A pointer to a buffer containing the new cell text. NULL can be specified to remove the cell text.

Returns

GetText returns the number of characters returned in the buffer, not including the terminating '\0'. The buffer must be large enough to receive the complete text. GetTextLength can be used to determine the buffer length needed. -1 is returned if an error occurred, for example if col is not a valid column number.

SetText returns TRUE if the function was successful, otherwise FALSE is returned.

Comments

The GetText and SetText functions define an item's cell text.

If the text of the currently selected item is changed using SetText, the static portion and the edit control portion of the combo box are updated to reflect the new text.

SftBox_GetLBText and SftBox_SetLBText are alternate names for the C functions SftBox_GetText and SftBox_SetText. They can be used interchangeably.

In a combo box control using a virtual data source, SetText cannot be used and an error is returned. The alpszString member of the SFTBOX_ITEM structure is used instead.

Examples

C View entire sample code

        CellInfo.Cell.colorBgEnd = CellInfo.Cell.colorBgSelEnd = SFTBOX_NOCOLOR;
        CellInfo.Cell.colorProgress = CellInfo.Cell.colorProgressEnd = SFTBOX_NOCOLOR;
        Sft_SetPictureColorSample(&CellInfo.Cell.CellPicture1, SAMPLE_SIZE, SAMPLE_SIZE, RGB(0, 0, 0), RGB(0, 0, 0));
        SftBox_SetCellInfo(hwndBox, &CellInfo);
    }

    // The color of each item is saved as its item data.
    index = SftBox_AddString(hwndBox, TEXT("Custom..."));
    SftBox_SetText(hwndBox, index, 1, TEXT("Any color"));
    SftBox_SetItemData(hwndBox, index, custom);
    SetColorSample(hwndBox, index, custom);

    for (i = 0 ; i < COLOR_COUNT ; ++i) {
        index = SftBox_AddString(hwndBox, m_aColors[i].lpszName);
        SftBox_SetText(hwndBox, index, 1, m_aColors[i].lpszDesc);
        SftBox_SetItemData(hwndBox, index, m_aColors[i].color);

C++ View entire sample code

        CellInfo.Cell.colorBgEnd = CellInfo.Cell.colorBgSelEnd = SFTBOX_NOCOLOR;
        CellInfo.Cell.colorProgress = CellInfo.Cell.colorProgressEnd = SFTBOX_NOCOLOR;
        Sft_SetPictureColorSample(&CellInfo.Cell.CellPicture1, SAMPLE_SIZE, SAMPLE_SIZE, RGB(0, 0, 0), RGB(0, 0, 0));
        box.SetCellInfo(&CellInfo);
    }

    // The color of each item is saved as its item data.
    index = box.AddString(_T("Custom..."));
    box.SetText(index, 1, _T("Any color"));
    box.SetItemData(index, custom);
    SetColorSample(box, index, custom);

    for (int i = 0 ; i < COLOR_COUNT ; ++i) {
        index = box.AddString(m_aColors[i].lpszName);
        box.SetText(index, 1, m_aColors[i].lpszDesc);
        box.SetItemData(index, m_aColors[i].color);

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


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