Hide

SftTree/DLL 7.5 - Tree Control

Display
Print

MakeSplitterOptimal

Positions the splitter bar optimally, so the left pane can display as much data as possible without a horizontal scroll bar.

C

void WINAPI SftTreeSplit_MakeSplitterOptimal(HWND hwndCtl);

C++

void CSftTreeSplit::MakeSplitterOptimal();

Parameters

hwndCtl

The window handle of the tree control.

Comments

The MakeSplitterOptimal function positions the splitter bar optimally, so the left pane can display as much data as possible without a horizontal scroll bar.

MakeSplitterOptimal is only available for a split tree control.

Before using MakeSplitterOptimal, the best horizontal extent for the panes must be set using SetHorizontalExtent or RecalcHorizontalExtent. Once set, MakeSplitterOptimal can then be used to position the splitter bar optimally, so the left pane can display as much data as possible without a horizontal scroll bar.

MakeSplitterOptimal uses the current width of the tree control window to determine the allowable position of the splitter bar. If the tree control window is too small, the splitter bar may not be optimally set. This is particularly noticeable if the tree control window is resized after MakeSplitterOptimal is used.

The coordinates of the splitter bar can be retrieved using GetSplitterRect.

SetSplitterWidth is used to change the width of the splitter bar.

Examples

C

            SFTTREE_COLORS Colors;
            SftTreeSplit_GetCtlColors(g_hwndTree, &Colors);/* Get current color settings */
            Colors.colorSelBgNoFocus = COLOR_BTNFACE | 0x80000000L;/* Selection background color (no input focus) */
            Colors.colorSelFgNoFocus = COLOR_BTNTEXT | 0x80000000L;/* Selection foreground color (no input focus) */
            SftTreeSplit_SetCtlColors(g_hwndTree, &Colors);/* Set new colors */
        }

        // In our example, we use SetCalcLimit(50) which will only consider 50 items when
        // MakeColumnOptimal, MakeRowHeaderOptimal or MakeSplitterOptimal is used.  Because our sample
        // data is wider at the end of the list, we'll change the TopIndex to the very last few items.
        // That way the last 50 items are analyzed.  In a typical application this is not necessary.
        SftTreeSplit_SetTopIndex(g_hwndTree, SftTreeSplit_GetCount(g_hwndTree) - 50);


        /* Make all column widths optimal, so text and pictures    */
        /* are not clipped horizontally.                           */

C++

        m_Tree.GetCtlColors(&Colors);    /* Get current color settings */
        Colors.colorTreeLines = COLOR_3DDKSHADOW | 0x80000000L;/* Tree line color */
        Colors.colorSelBgNoFocus = COLOR_BTNFACE | 0x80000000L;/* Selection background color (no input focus) */
        Colors.colorSelFgNoFocus = COLOR_BTNTEXT | 0x80000000L;/* Selection foreground color (no input focus) */
        m_Tree.SetCtlColors(&Colors);    /* Set new colors */
    }

    // In our example, we only consider 50 items when MakeColumnOptimal, MakeRowHeaderOptimal or
    // MakeSplitterOptimal is used.  Because our sample data is wider at the end of the list,
    // we'll change the TopIndex to the very last few items.
    // That way the last 50 items are analyzed.  In a typical application this is not necessary.
    m_Tree.SetTopIndex(m_Tree.GetCount() - 50);


    /* Make all column widths optimal, so text and pictures are */
    /* not clipped horizontally.                               */

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