SftTree/DLL 7.5 - Tree Control
SftBox/OCX 5.0 - Combo Box Control
SftButton/OCX 3.0 - Button Control
SftMask/OCX 7.0 - Masked Edit Control
SftTabs/OCX 6.5 - Tab Control (VB6 only)
SftTree/OCX 7.5 - Tree Control
SftPrintPreview/DLL 2.0 - Print Preview Control (discontinued)
SftTree/DLL 7.5 - Tree Control
SftBox/OCX 5.0 - Combo Box Control
SftButton/OCX 3.0 - Button Control
SftDirectory 3.5 - File/Folder Control (discontinued)
SftMask/OCX 7.0 - Masked Edit Control
SftOptions 1.0 - Registry/INI Control (discontinued)
SftPrintPreview/OCX 1.0 - Print Preview Control (discontinued)
SftTabs/OCX 6.5 - Tab Control (VB6 only)
SftTree/OCX 7.5 - Tree Control
SftTabs/NET 6.0 - Tab Control (discontinued)
SftTree/NET 2.0 - Tree Control
Sets the optimal column width so that the text and pictures of all items can be displayed without being clipped horizontally.
C
void WINAPI SftTree_MakeColumnOptimal(HWND hwndCtl, int realCol); void WINAPI SftTreeSplit_MakeColumnOptimal(HWND hwndCtl, int realCol);
C++
void CSftTree::MakeColumnOptimal(int realCol = -1, int limit = 0, BOOL fVisibleOnly = FALSE); void CSftTreeSplit::MakeColumnOptimal(int realCol = -1, int limit = 0, BOOL fVisibleOnly = FALSE);
hwndCtl
The window handle of the tree control.
realCol
The zero-based column number to resize so text and pictures are completely shown. Specify -1 to resize all columns optimally.
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.
The MakeColumnOptimal function sets the optimal column width so that the text and pictures of all items can be displayed without being clipped horizontally.
MakeColumnOptimal resizes a specified column or all columns to the optimal width so that the column header and each cell can be completely displayed without being truncated or clipped. CalcOptimalColumnWidth can be used to calculate a column's optimal width without resizing the column. The column width can be changed using SetColumns.
The SftTree_MakeColumnOptimal function does not support the parameters limit and fVisibleOnly. Use the SetCalcLimit and SetCalcVisibleOnly functions to supply this information before calling SftTree_MakeColumnOptimal.
By changing tree control attributes, the optimal column width may change. Adding items, setting new cell pictures 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.
The last (or only) column may be an "open-ended" column (see SetOpenEnded). An open-ended column will always use the space remaining between the previous column and the right edge of the tree control window. MakeColumnOptimal should be used even with an open-ended column, so the column width is optimal in case the user reorders the columns.
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 excluded from optimal column width calculation by setting the SFTTREECELL_IGNORE value in the flag2 member of the SFTTREE_CELL structure.
/* 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); // Set a timer so we can update our progress bars every once in a while
/* 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(); // Set a timer so we can update our progress bars every once in a while
See Also C/C++ API | Categories | Notifications