HeaderPane
Main
Hide
Share Link
Print

ItemLevel

Defines an item's level number.

C

int WINAPI SftBox_GetItemLevel(HWND hwndCtl, LONG index);
BOOL WINAPI SftBox_SetItemLevel(HWND hwndCtl, LONG indexTC, int level);

C++

int CSftBox::GetItemLevel(LONG index) const;
BOOL CSftBox::SetItemLevel(LONG indexTC, int level);

Parameters

hwndCtl

The window handle of the combo box control.

index, indexTC

The zero-based index of the item for which the level number is to be retrieved or set.

level

The new, zero-based level number of the item.

Returns

GetItemLevel returns the level number of the requested item or -1 if an error occurred.

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

Comments

The GetItemLevel and SetItemLevel functions define an item's level number.

If an item is not visible when its level is set, it is automatically made visible by expanding its parent item(s). If an item is collapsed when its level is set, it is first automatically expanded.

The root (or highest) level is level 0, dependent items are on levels 1, 2, 3 and lower. The lowest level is defined as level SFTBOX_MAXLEVELS (63). SetItemLevel adjusts a level value outside of this range to the nearest valid level.

The SetIndentation function can be used to define the exact indentation for item levels.

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

Examples

C View entire sample code

    SftBox_SetButtons(hwndBox, SFTBOX_BUTTON_AUTOMATIC);// Button style follows the Windows theme
    SftBox_SetDroppedHeight(hwndBox, 12);       // Show up to 12 items
    SftBox_SetDarkMode(hwndBox, SFTBOX_DARKMODE_AUTO);

    // The level of an item defines the hierarchy: an item is a
    // dependent of the closest preceding item with a lower level.
    for (i = 0 ; i < FOLDER_COUNT ; ++i) {
        LONG index = SftBox_AddString(hwndBox, m_aFolders[i].lpszText);
        SftBox_SetItemLevel(hwndBox, index, m_aFolders[i].level);
        if (m_aFolders[i].icon >= 0) {
            SFT_PICTURE Picture;
            Sft_InitPicture(&Picture);
            Sft_SetPictureIcon(&Picture, m_ahIcons[m_aFolders[i].icon]);
            SftBox_SetItemPicture(hwndBox, index, &Picture);// Override the default item picture
        }
    }

C++ View entire sample code

    m_Folders.SetButtons(SFTBOX_BUTTON_AUTOMATIC);// Button style follows the Windows theme
    m_Folders.SetDroppedHeight(12);     // Show up to 12 items
    m_Folders.SetDarkMode(SFTBOX_DARKMODE_AUTO);

    // The level of an item defines the hierarchy: an item is a
    // dependent of the closest preceding item with a lower level.
    for (i = 0 ; i < count ; ++i) {
        LONG index = m_Folders.AddString(aFolders[i].lpszText);
        m_Folders.SetItemLevel(index, aFolders[i].level);
        if (aFolders[i].icon >= 0) {
            SFT_PICTURE Picture;
            Sft_InitPicture(&Picture);
            Sft_SetPictureIcon(&Picture, m_ahIcons[aFolders[i].icon]);
            m_Folders.SetItemPicture(index, &Picture);// Override the default item picture
        }
    }

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


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