CTreeCtrl::GetLastVisibleItem

Retrieves the last unexpanded node item in the current tree-view control.

HTREEITEM GetLastVisibleItem() const;

Return Value

The handle to the last unexpanded node item if the method is successful; otherwise, NULL.

Remarks

This method sends the TVM_GETNEXTITEM message, which is described in the Windows SDK. For more information, see the TVGN_LASTVISIBLE flag in the flag parameter of that message.

Requirements

Header: afxcmn.h

Example

The following code example defines a variable, m_treeCtrl, that is used to access the current tree-view control. The code example also defines an unsigned integer and several HTREEITEM variables. One or more of these variables are used in the next example.

public:
    // Variable to access tree control.
    CTreeCtrl m_treeCtrl;
    // Variable to access splitbutton control.
    CSplitButton m_splitbutton;
    // Accessibility identifier
    UINT accIdUS;
    // HTREEITEMs
    HTREEITEM hCountry;
    HTREEITEM hPA;
    HTREEITEM hWA;

The following code example retrieves a handle to the last unexpanded tree-view node item, and then draws a 3D rectangle around that item. In an earlier section of the code example, which is not shown, we created a tree-view that consists of a root country node for the United States, subnodes for the states of Pennsylvania and Washington, and tree items for cities in those states.

    CRect rect;
    HTREEITEM hLast = m_treeCtrl.GetLastVisibleItem();
    m_treeCtrl.GetItemPartRect( hLast, TVGIPR_BUTTON, &rect );
    m_treeCtrl.GetDC()->Draw3dRect( &rect, RGB(255, 0, 0), RGB(0, 0, 255));

See Also

Reference

CTreeCtrl Class

Hierarchy Chart

TVM_GETNEXTITEM

Other Resources

CTreeCtrl Members