Hide

SftTree/DLL 7.5 - Tree Control

Display
Print

VirtualCount

Defines the number of items when using a virtual data source.

C

BOOL WINAPI SftTree_VirtualCount(HWND hwndCtl, LONG items,
        LONG itemsVisible,
        int maxLevels);
BOOL WINAPI SftTreeSplit_VirtualCount(HWND hwndCtl,
        LONG items,
        LONG itemsVisible,
        int maxLevels);

C++

BOOL CSftTree::VirtualCount(LONG items,
        LONG itemsVisible,
        int maxLevels = 0);
BOOL CSftTreeSplit::VirtualCount(LONG items,
        LONG itemsVisible,
        int maxLevels = 0);

Parameters

hwndCtl

The window handle of the tree control.

items

Specifies the current number of items to be managed by the tree control (including visible and hidden items).

itemsVisible

Specifies the current number of visible items to be managed by the tree control. For a flat list (without hierarchy) itemsVisible must be equal to items.

maxLevels

Specifies the lowest level on which any item can appear. For a flat list (without hierarchy) this value must be set to 0.

Returns

The return value is TRUE if the function was successful, otherwise FALSE is returned. If the tree control is not a virtual tree control (items have been adding using AddString or InsertString), this function will fail.

Comments

The VirtualCount function defines the number of items when using a virtual data source.

Whenever the number of items in the virtual data source changes, the application can call this function to notify the tree control.

VirtualInitialize must be used to initialize a tree control for use with a virtual data source.

GetCount can be used to retrieve the current number of items.

If the number of items is changed using VirtualCount, the tree control does not preserve the current index or the current selections. It is up to the application to preserve or update these.

Only flat lists (without hierarchy) are supported. To insure compatibility with future releases of SftTree/DLL, items and itemsVisible must be equal and maxLevels must be set to 0.

Examples

C

                SFTTREE_VERSION_700,
                0,
                Tree_VirtualStorageGetItemCallback,
                Tree_VirtualStorageReleaseItemCallback,
            };
            if (!SftTreeSplit_VirtualInitialize(g_hwndTree, &virt))
                ; /* error handling goes here */
            /* Set current number of items in the control.             */
            if (!SftTreeSplit_VirtualCount(g_hwndTree, 1000000L, 1000000L, 0))
                ; /* error handling goes here */
        }

        SftTreeSplit_SetShowHeader(g_hwndTree, TRUE);/* Show column headers */
        /* Define the background bitmap.                           */
        m_hBgBitmap = LoadBitmap(g_hInst, MAKEINTRESOURCE(IDB_BACKGROUND));/* Load a background bitmap */
        SftTreeSplit_SetBackgroundBitmap(g_hwndTree, m_hBgBitmap, 0, 0, 0);/* Define the background bitmap */

C++

            SFTTREE_VERSION_700,
            (SFTTREE_DWORD_PTR)(LPVOID)this,
            VirtualStorageGetItemCallback,
            VirtualStorageReleaseItemCallback,
        };
        if (!m_Tree.VirtualInitialize(&virt))
            return -1; /* error handling goes here */
        /* Set current number of items in the control.             */
        if (!m_Tree.VirtualCount(1000000L, 1000000L))
            return -1; /* error handling goes here */
    }

    m_Tree.SetShowHeader(TRUE);          /* Show column headers */
    m_BgBitmap.LoadBitmap(IDB_BACKGROUND);/* Load a background bitmap */
    m_Tree.SetBackgroundBitmap(m_BgBitmap, SFTTREE_BGBITMAP_HSCROLL, SFTTREE_BGBITMAP_CENTER);/* Define the background bitmap */

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