Hide

SftTree/DLL 7.5 - Tree Control

Display
Print

CalcOptimalColumnWidth

Calculates a column's optimal width so text and pictures are not clipped.

C

int WINAPI SftTree_CalcOptimalColumnWidth(HWND hwndCtl, int realCol);
int WINAPI SftTreeSplit_CalcOptimalColumnWidth(HWND hwndCtl, int realCol);

C++

int CSftTree::CalcOptimalColumnWidth(int realCol,
        int limit = 0,
        BOOL fVisibleOnly = FALSE);
int CSftTreeSplit::CalcOptimalColumnWidth(int realCol,
        int limit = 0,
        BOOL fVisibleOnly = FALSE);

Parameters

hwndCtl

The window handle of the tree control.

realCol

The zero-based column number whose optimal width is to be calculated.

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 cell's 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.

Returns

Returns the optimal column width in pixels. The return value is -1 if an error occurred.

Comments

The CalcOptimalColumnWidth function calculates a column's optimal width so text and pictures are not clipped.

CalcOptimalColumnWidth returns the optimal width of a specified column so that the column header's and each cell's text and picture can be completely displayed without being truncated or clipped. The column width can be changed using SetColumns. MakeColumnOptimal can be used to set a column's optimal width without having to calculate it first.

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

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

Items can be excluded from optimal column 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. Individual cells can be ignored from optimal column width calculation by setting the SFTTREECELL_IGNORE value in the flag2 member of the SFTTREE_CELL structure.

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