HeaderPane
Main
Hide
Share Link
Print

FindItem

Searches item data.

C

LONG WINAPI SftBox_FindItem(HWND hwndCtl, LONG index, SFTBOX_DWORD_PTR item);

C++

LONG CSftBox::FindItem(LONG index, SFTBOX_DWORD_PTR item) const;

Parameters

hwndCtl

The window handle of the combo box control.

index

The zero-based index of the item where the search for the specified data is to begin. This item is included in the search.

item

The value to be searched.

Returns

The return value is the zero-based index of the item where the item data was found. -1 is returned if the item data was not found or an error occurred.

Comments

The FindItem function searches item data.

The value of item is compared to the value returned by GetItemData for each item starting at index, up to the last item. If a matching value is found, its zero-based index is returned, otherwise -1 is returned.

Examples

C View entire sample code

        SftBox_SetItemData(hwndBox, index, m_aColors[i].color);
        SetColorSample(hwndBox, index, m_aColors[i].color);
    }

    SftBox_MakeColumnOptimal(hwndBox, -1, 0);   // Make all columns optimal
    SftBox_RecalcHorizontalExtent(hwndBox, 0);

    // Select the item with the requested color, searching after the custom color
    index = SftBox_FindItem(hwndBox, CUSTOM_INDEX + 1, selected);
    SftBox_SetCurSel(hwndBox, index >= 0 ? index : CUSTOM_INDEX);
}

static COLORREF GetSelectedColor(HWND hwndBox)
{
    LONG index = SftBox_GetCurSel(hwndBox);
    if (index < 0)

C++ View entire sample code

        box.SetItemData(index, m_aColors[i].color);
        SetColorSample(box, index, m_aColors[i].color);
    }

    box.MakeColumnOptimal(-1, 0);       // Make all columns optimal
    box.RecalcHorizontalExtent(0);

    // Select the item with the requested color, searching after the custom color
    index = box.FindItem(CUSTOM_INDEX + 1, selected);
    box.SetCurSel(index >= 0 ? index : CUSTOM_INDEX);
}

COLORREF CMainDlg::GetSelectedColor(const CSftBox& box) const
{
    LONG index = box.GetCurSel();
    if (index < 0)

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


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