HeaderPane
Main
Hide
Share Link
Print

ItemData

Defines an item's application-specific value.

C

SFTBOX_DWORD_PTR WINAPI SftBox_GetItemData(HWND hwndCtl, LONG indexTC);
int WINAPI SftBox_SetItemData(HWND hwndCtl, LONG indexTC, SFTBOX_DWORD_PTR dwd);

C++

SFTBOX_DWORD_PTR CSftBox::GetItemData(LONG indexTC) const;
int CSftBox::SetItemData(LONG indexTC, SFTBOX_DWORD_PTR dwd);

Parameters

hwndCtl

The window handle of the combo box control.

indexTC

The zero-based index of the item for which the application-defined value is to be retrieved or set.

dwd

The application-defined value to be associated with the specified item.

Returns

GetItemData returns the application-defined value specified for the item using SetItemData. If an invalid item index is specified, 0xFFFFFFFF is returned.

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

Comments

The GetItemData and SetItemData functions define an item's application-specific value.

The application-defined value can be used by an application to associate additional information with an item, such as a pointer to a structure with application-specific data. The deletion callback can be used for cleanup processing when items are deleted (see SetDeleteCallback).

FindItem can be used to locate an item based on its application-defined value.

SetCellInfo can be used to define an application-specific value associated with a cell (SFTBOX_CELL, cellData). SetUserData can be used to save an application-defined value associated with the combo box control.

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

Examples

C View entire sample code

        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);
        SetColorSample(hwndBox, index, m_aColors[i].color);

C++ View entire sample code

        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);
        SetColorSample(box, index, m_aColors[i].color);

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


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