Hide

SftTree/DLL 7.5 - Tree Control

Display
Print

ExpandCollapseIndex

Returns the zero-based index of the item to expand/collapse.

C

int WINAPI SftTree_GetExpandCollapseIndex(HWND hwndCtl);
int WINAPI SftTreeSplit_GetExpandCollapseIndex(HWND hwndCtl);

C++

int CSftTree::GetExpandCollapseIndex() const;
int CSftTreeSplit::GetExpandCollapseIndex() const;

Parameters

hwndCtl

The window handle of the tree control.

Returns

GetExpandCollapseIndex returns the zero-based index of the item to expand/collapse.

Comments

The GetExpandCollapseIndex function returns the zero-based index of the item to expand/collapse.

GetExpandCollapseIndex is used while handling notifications such as SFTTREEN_AUTOEXPANDING, SFTTREEN_LBUTTONDOWN_BUTTON, etc., to determine which item to expand or collapse.

GetExpandCollapseIndex returns the same value as GetCaretIndex (i.e., the current item) unless SetUpdateCaretExpandCollapse(FALSE) was used to initialize the tree control. In this case, GetExpandCollapseIndex returns the index of the item whose expand/collapse button was (double-)clicked.

Examples

C

            case IDC_TREE:
                switch(code) {
                case SFTTREEN_LBUTTONDBLCLK_TEXT:
                case SFTTREEN_LBUTTONDOWN_BUTTON:
                case SFTTREEN_LBUTTONDBLCLK_BUTTON: {
                    int index;
                    BOOL fExpand, fControl;
                    /* Get current position */
                    index = SftTree_GetExpandCollapseIndex(hwndCtl);/* Get caret location */
                    /* Check if item is expanded */
                    fExpand = SftTree_GetItemExpand(hwndCtl, index);
                    /* If the CONTROL key is pressed, expand all dependent levels */
                    fControl = (BOOL)(GetKeyState(VK_CONTROL)&0x8000);
                    if (fExpand)
                        SftTree_Collapse(hwndCtl, index, TRUE);
                    else

C++

/* Respond to events as the user clicks on different tree  */
/* components.  The events handled here can be changed to  */
/* suit your application.                                  */

void CSampleView::OnLButtonExpandCollapse()
{
    /* get index of item to expand/collapse */
    int index = m_Tree.GetExpandCollapseIndex();
    /* get current expand/collapsed status */
    BOOL fExpanded = m_Tree.GetItemExpand(index);
    /* if control key is used we'll expand all dependents */
    BOOL fDepth = (::GetKeyState(VK_CONTROL)&0x8000);

    if (fExpanded)
        m_Tree.Collapse(index, TRUE);
    else

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