HeaderPane
Main
Hide
Share Link
Print

ItemExpand

Defines an item's expand status.

C

BOOL WINAPI SftBox_GetItemExpand(HWND hwndCtl, int indexTC);
BOOL WINAPI SftBox_SetItemExpand(HWND hwndCtl, int indexTC, BOOL fExpand, BOOL fDepth);

C++

BOOL CSftBox::GetItemExpand(int indexTC) const;
BOOL CSftBox::SetItemExpand(int indexTC, BOOL fExpand, BOOL fDepth);

Parameters

hwndCtl

The window handle of the combo box control.

indexTC

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

fExpand

Set to TRUE to expand the item or FALSE to collapse the item.

fDepth

Set to TRUE to expand the item's indirect dependents in addition to the immediate dependents. This parameter is ignored if fExpand is set to FALSE.

Returns

GetItemExpand returns the current expand status of the specified item, TRUE if one or more dependent items are visible (the item is expanded), FALSE if no dependents are visible or if the item doesn't have any dependents.

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

Comments

The GetItemExpand and SetItemExpand functions define an item's expand status.

SetItemExpand does not preserve the expand/collapse state of dependent items. Use the Collapse and Expand functions instead, which can optionally preserve this information.

An item can be expanded/collapsed under program control using SetItemExpand. To determine if an item has dependent items and can be expanded, GetDependentCount can be used.

An item must currently be shown in order to be expanded or collapsed using this function. Use SetItemShown to make an item visible.

SetItemExpand only takes effect when an item has dependent items, otherwise it is ignored and SetItemExpand will return FALSE. This includes items marked as expandable using SetItemExpandable which have no dependent items. If the item is already in the requested state, TRUE is returned.

Unlike Collapse and Expand, SetItemExpand does not close the dropdown portion if it is currently shown.

Examples

C View entire sample code

// The combo box reports a click on an expand/collapse button, the
// application expands or collapses the item.

static void ExpandCollapse(HWND hwndBox)
{
    int index = SftBox_GetExpandCollapseIndex(hwndBox);
    if (index >= 0)
        SftBox_SetItemExpand(hwndBox, index, !SftBox_GetItemExpand(hwndBox, index), FALSE);
}

/**********************************************************************/
/*                           Dialog Proc                              */
/**********************************************************************/

INT_PTR CALLBACK MainDialogProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{

C++ View entire sample code

// The combo box reports a click on an expand/collapse button, the
// application expands or collapses the item.

void CMainDlg::OnFoldersExpandCollapse()
{
    int index = m_Folders.GetExpandCollapseIndex();
    if (index >= 0)
        m_Folders.SetItemExpand(index, !m_Folders.GetItemExpand(index), FALSE);
}

BOOL CMainDlg::OnInitDialog()
{
    CDialog::OnInitDialog();

    SetIcon(m_hIcon, TRUE);   // Set big icon
    SetIcon(m_hIcon, FALSE);  // Set small icon

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


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