HeaderPane
Main
Hide
Share Link
Print

Collapse

Collapses a parent item.

C

BOOL WINAPI SftBox_Collapse(HWND hwndCtl, int indexTC, BOOL fPreserve);

C++

BOOL CSftBox::Collapse(int indexTC, BOOL fPreserve);

Parameters

hwndCtl

The window handle of the combo box control.

indexTC

The zero-based index of the item to be collapsed. If -1 is specified, all items on level 0 are collapsed.

fPreserve

Set to TRUE to preserve the expand/collapse state of dependent items made no longer visible. A subsequent call to Expand with its fPreserve parameter set to TRUE (and fDepth set to FALSE) restores the items with the remembered expand/collapse state. If FALSE is specified, the expand/collapse state is not preserved.

Returns

The return value is TRUE if successful, otherwise FALSE is returned.

Comments

The Collapse function collapses a parent item.

Collapse collapses the specified parent item, hides all dependent items and saves the expand/collapse state of all dependent items (if fPreserve is set to TRUE), so it can be restored by a subsequent call to Expand.

If the dropdown portion of a dropdown or dropdown list combo box is visible, it is hidden when Collapse is called. This can be suppressed using SetRollupOnChange.

In a combo box control using a virtual data source, this function cannot be used.

Examples

C View entire sample code

        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
        }
    }

    // Collapse the top level items
    for (i = 0 ; i < FOLDER_COUNT ; ++i) {
        if (m_aFolders[i].level == 0)
            SftBox_Collapse(hwndBox, i, TRUE);
    }
    SftBox_Expand(hwndBox, 0, TRUE, FALSE);     // Show the dependents of the first item

    SftBox_RecalcHorizontalExtent(hwndBox, 0);

C++ View entire sample code

        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
        }
    }

    // Collapse the top level items
    for (i = 0 ; i < count ; ++i) {
        if (aFolders[i].level == 0)
            m_Folders.Collapse(i, TRUE);
    }
    m_Folders.Expand(0, TRUE, FALSE);   // Show the dependents of the first item

    m_Folders.RecalcHorizontalExtent(0);

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


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