Hide

SftTree/DLL 7.5 - Tree Control

Display
Print

TopIndex

Defines the index number of the item shown at the top of the tree control.

C

int WINAPI SftTree_GetTopIndex(HWND hwndCtl);
int WINAPI SftTree_SetTopIndex(HWND hwndCtl, int index);
int WINAPI SftTreeSplit_GetTopIndex(HWND hwndCtl);
int WINAPI SftTreeSplit_SetTopIndex(HWND hwndCtl, int index);

C++

int CSftTree::GetTopIndex() const;
int CSftTree::SetTopIndex(int index);
int CSftTreeSplit::GetTopIndex() const;
int CSftTreeSplit::SetTopIndex(int index);

Parameters

hwndCtl

The window handle of the tree control.

index

The zero-based index of the item which will become the first item displayed.

Returns

GetTopIndex returns the zero-based index of the item that is displayed as the first item in the tree control's client area.

SetTopIndex returns 0 if the function was successful, otherwise -1 is returned.

Comments

The GetTopIndex and SetTopIndex functions define the index number of the item shown at the top of the tree control.

An item must be visible before it can be displayed as the first item. SetItemShown can be used to make an item visible.

Examples

C

        /* Make row header width optimal, so text and pictures are */
        /* not clipped horizontally.                               */
        SftTree_MakeRowHeaderOptimal(g_hwndTree);/* Make row header width optimal */
        SftTree_RecalcHorizontalExtent(g_hwndTree);/* Update horizontal scroll bar */

        SftTree_SetCurSel(g_hwndTree, 4); // select the 4th item
        SftTree_SetCaretIndex(g_hwndTree, 4); // and make it current
        SftTree_SetTopIndex(g_hwndTree, 0); // show the first item

        return 0;
     }
    case WM_DESTROY:
        DeleteObject(m_aThreeItemPictures[0].Picture.hBitmap);/* Default item pictures */
        DeleteObject(m_aThreeItemPictures[1].Picture.hBitmap);
        DeleteObject(m_aThreeItemPictures[2].Picture.hBitmap);
        //DeleteObject(m_OtherItemPicture.Picture.hBitmap);/* Another item picture */

C++

    m_Tree.MakeColumnOptimal(-1, 0, FALSE);/* Make column widths optimal */
    /* Make row header width optimal, so text and pictures are  */
    /* not clipped horizontally.                               */
    m_Tree.MakeRowHeaderOptimal(0, FALSE);/* Make row header width optimal */
    m_Tree.RecalcHorizontalExtent(0, FALSE);/* Update horizontal scroll bar */

    m_Tree.SetCurSel(4); // select the 4th item
    m_Tree.SetCaretIndex(4); // and make it current
    m_Tree.SetTopIndex(0); // show the first item

    return 0;
}

void CSampleView::OnSize(UINT nType, int cx, int cy) 
{
    CView::OnSize(nType, cx, cy);

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