HeaderPane
Main
Hide
Share Link
Print

Expand

Expands a parent item.

C

BOOL WINAPI SftBox_Expand(HWND hwndCtl, int indexTC, BOOL fPreserve, BOOL fDepth);

C++

BOOL CSftBox::Expand(int indexTC, BOOL fPreserve, BOOL fDepth);

Parameters

hwndCtl

The window handle of the combo box control.

indexTC

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

fPreserve

Set to TRUE to restore the expand/collapse state of dependent items made visible, as saved by a previous call to Collapse. If FALSE is specified, only the item defined by indexTC is expanded and immediate dependents are made visible but remain collapsed.

fDepth

Set to TRUE to expand all dependent items, including non-immediate dependent items. If TRUE is specified, fPreserve is ignored as all dependents are expanded.

Returns

The return value is TRUE if indexTC is a valid item index or -1, otherwise FALSE is returned. TRUE is also returned if the item could not be expanded, for example because it has no dependent items or is not visible.

Comments

The Expand function expands a parent item.

Expand makes the dependent items of item indexTC visible and can restore the expand/collapse state of all dependent items, as saved by a previous call to Collapse.

If an item is already expanded when using Expand, the item remains unchanged and Expand with fDepth set to TRUE does not make its indirect dependents visible. To make sure that an item's indirect dependents are shown, use Collapse first, which collapses the item (and all dependents), followed by Expand with fDepth set to TRUE.

If the dropdown portion of a dropdown or dropdown list combo box is currently shown, it is closed when Expand is called. This can be suppressed using SetRollupOnChange.

In a combo box control using a virtual data source, -1 cannot be used as indexTC and an error is returned.

Examples

C View entire sample code

        }
    }

    // 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);
    SftBox_SetCurSel(hwndBox, 0);
}

/**********************************************************************/
/*                 Item Pictures and a Button Picture                 */

C++ View entire sample code

        }
    }

    // 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);
    m_Folders.SetCurSel(0);
}

void CMainDlg::InitDevices()
{

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


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