Calculates the optimal width for row headers so text and pictures are not clipped.
C
int WINAPI SftBox_CalcOptimalRowHeaderWidth(HWND hwndCtl, LONG maximum);
C++
int CSftBox::CalcOptimalRowHeaderWidth(LONG maximum) const;
hwndCtl
The window handle of the combo box control.
maximum
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 combo box 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 maximum items, located around the items currently shown at the top of the dropdown portion. This results in better response time, yet some items which are not within the number of scanned items may still be clipped.
The return value is the optimal row header area width in pixels. The return value is 0 if row headers are not shown (see SetShowRowHeader).
The CalcOptimalRowHeaderWidth function calculates the optimal width for row headers so text and pictures are not clipped.
CalcOptimalRowHeaderWidth calculates the optimal width of the row header area so that the row header text and pictures and (if column headers are shown) the row/column header's text and picture can be completely displayed without being truncated or clipped, in the dropdown portion and in the static portion of the combo box control. The row header width can be changed using SetRowHeaderWidth. MakeRowHeaderOptimal can be used to set the optimal row header width without having to calculate it first.
Only visible items are considered. Items which are not visible because their parent items are collapsed are not included in the width calculation.
By changing combo box 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 combo box control does not automatically adjust the row header width.
In a combo box control using a virtual data source, items can be excluded from the dropdown portion's optimal row header width calculation by setting the SFTBOXITEM_IGNORE value in the flag2 member of the SFTBOX_ITEM structure. The selected item shown in the static portion is always included.
See Also C/C++ API | Categories | Notifications