A combo box control can allow the user to resize columns. By dragging the separator between two column headers, users can adjust column widths to their particular needs. Column resizing is enabled using SetResizeHeader. As the column headers are used to resize a column, columns can only be resized by the user if column headers are shown (see Column Headers).
Columns can be resized using the column headers of the dropdown portion or the column headers above the static portion or edit control portion. The new column widths always apply to both portions. Resizing columns in the dropdown portion does not close the dropdown portion.
The parent window receives the following notifications as WM_COMMAND messages while the user resizes a column.
| Notification | Sent when |
|---|---|
| SFTBOXN_COLUMNSIZESTARTED | The user has pressed a mouse button on the resizing area and is about to resize a column. |
| SFTBOXN_COLUMNSIZE | The column widths have changed. |
| SFTBOXN_COLUMNSIZEENDED | The resizing operation has ended, because the user released the mouse button or because the operation was canceled. |
The new column widths can be retrieved using GetColumns (width member of each SFTBOX_COLUMN structure). An application can save the column widths and restore them the next time the combo box is created.
If the user double-clicks the resizing area of a column header, the SFTBOXN_LBUTTONDBLCLK_COLUMNRES notification is sent (wrapped using SFTBOXN_MAIN_NOTIFICATION if the column headers above the static portion or edit control portion are used). The combo box does not resize the column. While the notification is handled, GetResizeColumn returns the column number of the column whose resizing area was double-clicked. An application typically responds by making the column as wide as its contents using MakeColumnOptimal.
case SFTBOXN_LBUTTONDBLCLK_COLUMNRES: case SFTBOXN_MAIN_NOTIFICATION(SFTBOXN_LBUTTONDBLCLK_COLUMNRES): { int col = SftBox_GetResizeColumn(hwndBox); if (col >= 0) { SftBox_MakeColumnOptimal(hwndBox, col, 0); SftBox_RecalcHorizontalExtent(hwndBox, 0); } break; }
A column can be defined with a minimum width (minWidth member of the SFTBOX_COLUMN structure). The user cannot make the column smaller than this width, which prevents the user from hiding the column. The minimum width also applies when the application defines the column width using SetColumns or MakeColumnOptimal. A smaller width is increased to the minimum width, for all columns except the last displayed column.
A column can be locked by adding SFTBOX_COL_LOCKED to the colFlag member of its SFTBOX_COLUMN structure. A locked column cannot be resized by the user. This is useful for a column that only contains pictures of the same width. Locked columns can also be used to hide a column: a locked column with a width of 0 is not visible and cannot be made visible by the user, yet the application can still use its cell text.
If the user makes a column so small that its width becomes 0, the resizing operation can continue with the next column to the left, making it smaller also. SetCrossColumnResize defines whether more than one column can be affected by one resizing operation. This is disabled by default, so the user cannot hide several columns with one resizing operation.
If the last displayed column is open-ended (see SetOpenEnded), it uses all the space remaining up to the right edge of the portion, but at least its defined width. An open-ended last column cannot be resized by the user. In a combo box with one column, the column can only be resized by the user if it is not open-ended.