Hide

SftTree/DLL 7.5 - Tree Control

Display
Print

MakeRowHeaderOptimal

Sets the optimal row header width so that the text and pictures of all row headers can be displayed.

C

int SftTree_MakeRowHeaderOptimal(HWND hwndCtl);
int SftTreeSplit_MakeRowHeaderOptimal(HWND hwndCtl);

C++

void CSftTree::MakeRowHeaderOptimal(int limit = 0, BOOL fVisibleOnly = FALSE);
void CSftTreeSplit::MakeRowHeaderOptimal(int limit = 0, BOOL fVisibleOnly = FALSE);

Parameters

hwndCtl

The window handle of the tree control.

limit

Defines the maximum number of items to be considered for width calculation. Specify a number less than or equal to 0 to consider all items. If a tree control contains many items, scanning all items may be extremely slow, as each row header width needs to be calculated. Using an application defined maximum number, the calculation can be limited to limit items. This results in better response time, yet some items which are not within the number of scanned items may still be clipped.

fVisibleOnly

Specify TRUE to limit the width calculation to visible items only. Items which are not visible because their parent items are collapsed are not included in the width calculation.

Comments

The MakeRowHeaderOptimal function sets the optimal row header width so that the text and pictures of all row headers can be displayed.

MakeRowHeaderOptimal resizes the row header area so that the row header text and row header pictures can be completely displayed without being truncated or clipped. CalcOptimalRowHeaderWidth can be used to calculate a column's optimal width without resizing the row header area. The row header width can be changed using SetRowHeaderWidth.

The SftTree_MakeRowHeaderOptimal function does not support the parameters limit and fVisibleOnly. Use the SetCalcLimit and SetCalcVisibleOnly functions to supply this information before calling SftTree_MakeRowHeaderOptimal.

By changing tree control attributes, the optimal row header width may change. Adding items, setting new row header pictures and changing row header text are a few of the actions that can affect the optimal row header width. The row header width may have to be set again to allow items to be completely visible. The tree control does not automatically adjust the row header width.

Items can be excluded from optimal row header width calculation by using the SetItemIgnore function or for virtual mode, setting the SFTTREEITEM_IGNORE value in the flag2 member of the SFTTREE_ITEM structure.

Examples

C

        /*------------------------------------------------------------------------------*/
        /* Once ALL TREE CONTROL ITEMS HAVE BEEN ADDED, you can set additional tree     */
        /* control attributes.                                                          */
        /*------------------------------------------------------------------------------*/

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

        SftTree_MakeColumnOptimal(g_hwndTree, 0);/* Only make the first column optimal */
        SftTree_RecalcHorizontalExtent(g_hwndTree);/* Update horizontal scroll bar */

        SftTree_SetCaretIndex(g_hwndTree, 0);
        SftTree_SetCurSel(g_hwndTree, 0);
        CopyPictureFromCurrentItem(g_hwndTree);

C++

    /*------------------------------------------------------------------------------*/
    /* Once ALL TREE CONTROL ITEMS HAVE BEEN ADDED, you can set additional tree     */
    /* control attributes.                                                          */
    /*------------------------------------------------------------------------------*/
    
    /* 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.MakeColumnOptimal(0);/* Only make the first column optimal */
    m_Tree.RecalcHorizontalExtent(0, FALSE);/* Update horizontal scroll bar */

    m_Tree.SetCaretIndex(0);
    m_Tree.SetCurSel(0);
    CopyPictureFromCurrentItem();

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