The SFTBOX_COLUMN structure is used with GetColumns and SetColumns to retrieve and set column attributes.
typedef struct tagSftBoxColumn {
DWORD res1; // reserved - must be 0
DWORD res2; // reserved - must be 0
int width; // column width
DWORD style; // column cell alignment
// use ES_LEFT, ES_CENTER, ES_RIGHT edit window styles
// SFTBOX_MULTILINE if more than one text line
#define SFTBOX_MULTILINE ES_MULTILINE // allow \r\n
#define SFTBOX_WRAP 0x0010L // wrap text (combine with SFTBOX_MULTILINE)
#define SFTBOX_TOOLTIP 0x0008L // enable tooltips
DWORD styleTitle; // column title style
// use ES_LEFT, ES_CENTER, ES_RIGHT edit window styles
// and SFTBOX_HEADER_DISABLED/UP
// Do not write to the string addressed directly
LPTSTR lpszTitle; // column title
LPTSTR lpszOrig; // original column title - do not alter
HBITMAP obsoletehBmp; // not used
short flag; // misc flag (for picture position)
short flag2; // reserved
short flag3; // reserved
short flag4; // reserved
COLORREF colorBg; // column cell colors (override default colors)
COLORREF colorFg;
COLORREF colorBgSel;
COLORREF colorFgSel;
/* Column display */
int realPos; // column real position
int dispPos; // column display position
short colFlag; // column flag
#define SFTBOX_COL_LOCKED 0x01 // lock column (can't resize)
#define SFTBOX_COL_KEEPPOS 0x02 // column must stay in position
#define SFTBOX_COL_MERGE 0x04 // column can merge into next
#define SFTBOX_COL_MERGEINTO 0x08 // column allows merge into from previous
#define SFTBOX_COL_SORTED_ASC 0x10 // column header shows sort ascending
#define SFTBOX_COL_SORTED_DESC 0x20 // column header shows sort descending
short minWidth; // minimum column width
short flag6; // reserved
short flag7; // reserved
SFT_PICTURE Picture1; // column header picture
int fColorsOverrideTheme; // TRUE if this header's colors override Windows theme colors
COLORREF headerColorBg; // column header's background color
COLORREF headerColorFg; // column header's foreground color
COLORREF headerColorBgSel; // column header's background color if selected
COLORREF headerColorFgSel; // column header's foreground color if selected
COLORREF headerColorBgDisabled; // column header's background color if disabled
COLORREF headerColorFgDisabled; // column header's foreground color if disabled
COLORREF headerColorBgSelDisabled; // column header's background color if disabled and selected
COLORREF headerColorFgSelDisabled; // column header's foreground color if disabled and selected
COLORREF colorBgEnd; // column's cell default background color (ending color for gradient fill)
COLORREF colorBgSelEnd; // column's cell default background color if selected (ending color for gradient fill)
COLORREF colorProgress; // column's default progress bar color
COLORREF colorProgressEnd; // column's default progress bar color (ending color for gradient fill)
} SFTBOX_COLUMN, * LPSFTBOX_COLUMN;
typedef const SFTBOX_COLUMN * LPCSFTBOX_COLUMN;res1, res2
Reserved. Must be set to 0.
The width of the column (in pixels). Specify a width greater or equal to 0. A hidden column has a width of 0. The last column also must have a defined width, even if it is defined as an open-ended column (see SetOpenEnded). An open-ended last column will display the complete text specified for the last (or only) column and never truncate any data. A fixed-width last column is defined with a specified width and any data which doesn't fit is truncated.
The width defined must be larger or equal to minWidth. minWidth defines the minimum width of the column.
The item style and alignment default used for the column. This value applies to all cells in this column.
One value of each of the following tables can be combined and assigned to the style member.
| style | Horizontal cell text alignment |
|---|---|
| not specified | If no horizontal cell text alignment is specified, the default is ES_LEFT. |
| ES_LEFT | The cell text is left aligned within the cell. Cells can override this default by defining new alignment values using the SFTBOX_CELL, flag member. |
| ES_CENTER | The cell text is centered within the cell. Cells can override this default by defining new alignment values using the SFTBOX_CELL, flag member. |
| ES_RIGHT | The cell text is right aligned within the cell. Cells can override this default by defining new alignment values using the SFTBOX_CELL, flag member. |
| style | Vertical cell text alignment |
|---|---|
| not specified | If no vertical cell text alignment is specified, the default is SFTBOX_VCENTER. |
| SFTBOX_TOP | The cell text and cell picture are aligned with the top of the cell. Cells can override this default by defining new alignment values using the SFTBOX_CELL, flag member. |
| SFTBOX_VCENTER | The cell text and cell picture are vertically centered within the cell. Cells can override this default by defining new alignment values using the SFTBOX_CELL, flag member. |
| SFTBOX_BOTTOM | The cell text and cell picture are aligned with the bottom of the cell. Cells can override this default by defining new alignment values using the SFTBOX_CELL, flag member. |
The style value can optionally be combined with one or more of the following values:
| style | Cell attributes |
|---|---|
| SFTBOX_MULTILINE | Cell text can contain new-line characters ('\n') to indicate the start of a new line. Also use SetItemLines, so the item height can be properly determined. |
| SFTBOX_WRAP | Cell text will word wrap within the available cell width and height. Specify SFTBOX_WRAP together with SFTBOX_MULTILINE. |
| SFTBOX_TOOLTIP | ToolTips are displayed in this column for truncated cells. |
The column header style used for the column header.
One value of each of the following tables can be combined and assigned to the styleTitle member.
| styleTitle | Horizontal column header text alignment |
|---|---|
| not specified | If no horizontal column header text alignment is specified, the default is ES_LEFT. |
| ES_LEFT | The column header text is left aligned within the column header. |
| ES_CENTER | The column header text is centered within the column header. |
| ES_RIGHT | The column header text is right aligned within the column header. |
| styleTitle | Vertical column header text alignment |
|---|---|
| not specified | If no vertical column header alignment is specified, the default is SFTBOX_VCENTER. |
| SFTBOX_TOP | The column header text and picture are aligned with the top of the column header. |
| SFTBOX_VCENTER | The column header text and picture are vertically centered within the column header. |
| SFTBOX_BOTTOM | The column header text and picture are aligned with the bottom of the column header. |
The styleTitle value can optionally be combined with one or more of the following values:
| styleTitle | Column header attributes |
|---|---|
| SFTBOX_HEADER_DISABLED | The column header for the column is disabled, cannot be clicked and is displayed in a "grayed" fashion. The column contents (cells) are otherwise unaffected. |
| SFTBOX_HEADER_UP | The column header button will automatically return to its "up" position when clicked. |
The column header title. This member may be NULL to indicate that no title is specified for the column. In the array returned by GetColumns, do not modify the string. To change the title, replace the pointer with a pointer to a new string before calling SetColumns. The column header title can also be retrieved and set using GetHeader and SetHeader.
Reserved. Do not alter. Set to NULL when initializing a SFTBOX_COLUMN structure. In the array returned by GetColumns, this member holds the column title allocated by the combo box, which the combo box frees.
Not used. Set to NULL when initializing a SFTBOX_COLUMN structure.
The picture location relative to the column header text. This member is ignored if Picture1 is empty.
One value of each of the following tables can be combined and assigned to the flag member.
| flag | Horizontal column header picture alignment |
|---|---|
| SFTBOX_BMP_LEFT | The column header picture is displayed to the left of the column header text. If no horizontal column header picture alignment value is specified, SFTBOX_BMP_LEFT is assumed. |
| SFTBOX_BMP_CENTER | The column header picture is displayed in the center of the column header, the column header text is not shown. |
| SFTBOX_BMP_RIGHT | The column header picture is displayed to the right of the column header text. |
| flag | Vertical column header picture alignment |
|---|---|
| SFTBOX_BMP_VCENTER | The column header picture is vertically centered within the column header. If no vertical column header alignment value is specified, SFTBOX_BMP_VCENTER is assumed. |
| SFTBOX_BMP_TOP | The column header picture is vertically aligned with the top of the column header. |
| SFTBOX_BMP_BOTTOM | The column header picture is vertically aligned with the bottom of the column header. |
Reserved. Set to 0 when initializing a SFTBOX_COLUMN structure.
The default background color used to draw cells that are not selected. Specify SFTBOX_NOCOLOR to use the default color. Cells can override the default background color using SFTBOX_CELL, colorBg.
The default foreground color used to draw cells that are not selected. Specify SFTBOX_NOCOLOR to use the default color. Cells can override the default foreground color using SFTBOX_CELL, colorFg.
The default background color used to draw cells that are selected. Specify SFTBOX_NOCOLOR to use the default color. Cells can override the background color using SFTBOX_CELL, colorBgSel.
The default foreground color used to draw cells that are selected. Specify SFTBOX_NOCOLOR to use the default color. Cells can override the foreground color using SFTBOX_CELL, colorFgSel.
This member is read/only and cannot be set by the application. SetColumns ignores the value in this member. realPos is used to convert a display column number into a real column number. As a user reorders columns (see SetReorderColumns), the real column number used by an application differs from the display column number (see GetRealColumn and GetDisplayColumn).
This member specifies the zero-based display position of the column. As a user reorders columns (see SetReorderColumns), the real column number used by an application differs from the display column number. dispPos contains the actual (visible) column number the real column represents. An application can set this member to 0 (for all columns) so real and display column numbers are identical, otherwise a display column number can be specified for each column.
The column attributes. The following values can be combined:
| colFlag | Column attributes |
|---|---|
| SFTBOX_COL_LOCKED | This style causes the column to be a fixed-width column so the user cannot resize it even if column resizing has been allowed (see SetResizeHeader). By defining a column as locked and specifying a width of 0, a column can be hidden from the user. |
| SFTBOX_COL_KEEPPOS | This style causes the column to remain in the current display position even if column reordering has been allowed (see SetReorderColumns). Typically, column 0 could be locked in place, so the user always has the most important data shown first. |
| SFTBOX_COL_MERGE | Allows the contents of this column to merge into the next displayed column if the contents of the next cell (or column header) are empty and the next column allows being merged into (SFTBOX_COL_MERGEINTO). This style also applies to column headers. |
| SFTBOX_COL_MERGEINTO | Allows the contents of the previous column to merge into this column if the cell (or column header) in this column is empty. This style also applies to column headers. |
| SFTBOX_COL_SORTED_ASC | The column header displays a sort indicator representing ascending sorting if sort indicators are enabled using EnableSortIndicators. SFTBOX_COL_SORTED_ASC cannot be used at the same time as SFTBOX_COL_SORTED_DESC. |
| SFTBOX_COL_SORTED_DESC | The column header displays a sort indicator representing descending sorting if sort indicators are enabled using EnableSortIndicators. SFTBOX_COL_SORTED_DESC cannot be used at the same time as SFTBOX_COL_SORTED_ASC. |
The minimum width of the column (in pixels). Specify a minimum width greater or equal to 0. If a value greater than 0 is specified, the user cannot make this column smaller than the specified value by resizing the column. When columns are defined using SetColumns, a width smaller than minWidth is increased to minWidth (except for the last displayed column). If minWidth is 0, the column has no minimum width.
Reserved. Set to 0 when initializing a SFTBOX_COLUMN structure.
Defines the picture displayed in the column header, next to the column header text. The picture position is defined using the flag member.
Defines whether an application can override Windows themes and the column header colors are used to render the column header. Set to TRUE to use the defined colors (headerColorBg, headerColorBgSel, headerColorBgDisabled, headerColorBgSelDisabled, headerColorFg, headerColorFgSel, headerColorFgDisabled, headerColorFgSelDisabled) instead of Windows themes, otherwise set to FALSE. If all colors are set to their default value (SFTBOX_NOCOLOR), Windows themes are used. The column header background colors (headerColorBg, headerColorBgSel, headerColorBgDisabled, headerColorBgSelDisabled) are only used if fColorsOverrideTheme is TRUE, even if Windows themes are not used.
The background color used to render this column's header, when fColorsOverrideTheme is TRUE. Specify SFTBOX_NOCOLOR to use the default color (defined using SFTBOX_COLORS, colorColHdrBg).
The text color used to render this column's header, when Windows themes are not used or the application can override themes (fColorsOverrideTheme). Specify SFTBOX_NOCOLOR to use the default color (defined using SFTBOX_COLORS, colorColHdrFg).
The background color used to render this column's header when it is pressed and fColorsOverrideTheme is TRUE. Specify SFTBOX_NOCOLOR to use the default color (headerColorBg).
The text color used to render this column's header when it is pressed and Windows themes are not used or the application can override themes (fColorsOverrideTheme). Specify SFTBOX_NOCOLOR to use the default color (headerColorFg).
The background color used to render this column's header when it is disabled and fColorsOverrideTheme is TRUE. Specify SFTBOX_NOCOLOR to use the default color (defined using SFTBOX_COLORS, colorColHdrBg).
The text color used to render this column's header when it is disabled and Windows themes are not used or the application can override themes (fColorsOverrideTheme). Specify SFTBOX_NOCOLOR to use the default color (defined using SFTBOX_COLORS, colorColHdrFgGrayed).
The background color used to render this column's header when it is pressed and disabled and fColorsOverrideTheme is TRUE. Specify SFTBOX_NOCOLOR to use the default color (headerColorBgDisabled).
The text color used to render this column's header when it is pressed and disabled and Windows themes are not used or the application can override themes (fColorsOverrideTheme). Specify SFTBOX_NOCOLOR to use the default color (headerColorFgDisabled).
The default ending background color used to draw cells that are not selected. Specify SFTBOX_NOCOLOR if no gradient fill is wanted. If colorBg is not defined, colorBgEnd is ignored. Cells can override the default background color using SFTBOX_CELL, colorBgEnd. colorBgEnd combined with colorBg define a gradient fill used to render the cell's background. Cells can define the gradient fill orientation using SFTBOX_CELL, flag3.
The default ending background color used to draw cells that are selected. Specify SFTBOX_NOCOLOR if no gradient fill is wanted. If colorBgSel is not defined, colorBgSelEnd is ignored. Cells can override the default background color using SFTBOX_CELL, colorBgSelEnd. colorBgSelEnd combined with colorBgSel define a gradient fill used to render the selected cell's background. Cells can define the gradient fill orientation using SFTBOX_CELL, flag3.
The default color used to draw a progress bar. Specify SFTBOX_NOCOLOR to use the system highlight color (COLOR_HIGHLIGHT). Cells can override the default color using SFTBOX_CELL, colorProgress. A progress bar is only shown if a cell's SFTBOX_CELL, progressMax value has been set to a value greater than 0.
The default ending color used to draw a progress bar. Specify SFTBOX_NOCOLOR if no gradient fill is wanted. If colorProgress is not defined, colorProgressEnd is ignored. Cells can override the default color using SFTBOX_CELL, colorProgressEnd. colorProgressEnd combined with colorProgress define a gradient fill used to render the progress bar. Cells can define the gradient fill orientation using SFTBOX_CELL, flag3. A progress bar is only shown if a cell's SFTBOX_CELL, progressMax value has been set to a value greater than 0. h1 Comments
The SFTBOX_COLUMN structure is used with GetColumns and SetColumns to retrieve and set column attributes. The column definitions apply to the dropdown portion and the static portion of the combo box control.
When defining columns, all members of each SFTBOX_COLUMN structure must be initialized. Members that are not used are set to 0 and color members for which the default color is to be used are set to SFTBOX_NOCOLOR. To modify the attributes of existing columns, an application retrieves the current column definitions using GetColumns, modifies the desired members and calls SetColumns.
Due to the variable number of levels and the resulting hierarchical display, the width of the first column is always treated as a minimum width. The text portion of the first column will always be at least of the specified width, no matter what level the item is on. This can result in the first column being much wider than the defined width. Use GetOverheadWidth to calculate the actual width of the first column.
An RGB value or a GetSysColor index value can be specified for all color values. If a color index is used, the high-order bit must be set (e.g., COLOR_WINDOW | 0x80000000L).
Pointer typedefs: LPSFTBOX_COLUMN is a pointer to a SFTBOX_COLUMN structure, LPCSFTBOX_COLUMN is a pointer to a constant SFTBOX_COLUMN structure.
return GetSysColor((int)(color & 0xff));
return color;
}
/**********************************************************************/
/* Combo Box Setup */
/**********************************************************************/
static void InitColumn(LPSFTBOX_COLUMN lpCol, int position, int width, LPCTSTR lpszTitle)
{
memset(lpCol, 0, sizeof(SFTBOX_COLUMN));
lpCol->width = width;
lpCol->style = ES_LEFT | SFTBOX_TOOLTIP;
lpCol->styleTitle = ES_LEFT | SFTBOX_HEADER_UP;
lpCol->lpszTitle = (LPTSTR) lpszTitle;
lpCol->colorBg = lpCol->colorFg = lpCol->colorBgSel = lpCol->colorFgSel = SFTBOX_NOCOLOR;
static COLORREF ResolveColor(COLORREF color)
{
if (color & 0x80000000L)
return GetSysColor((int)(color & 0xff));
return color;
}
static void InitColumn(LPSFTBOX_COLUMN lpCol, int position, int width, LPCTSTR lpszTitle)
{
memset(lpCol, 0, sizeof(SFTBOX_COLUMN));
lpCol->width = width;
lpCol->style = ES_LEFT | SFTBOX_TOOLTIP;
lpCol->styleTitle = ES_LEFT | SFTBOX_HEADER_UP;
lpCol->lpszTitle = (LPTSTR) lpszTitle;
lpCol->colorBg = lpCol->colorFg = lpCol->colorBgSel = lpCol->colorFgSel = SFTBOX_NOCOLOR;
lpCol->colorBgEnd = lpCol->colorBgSelEnd = SFTBOX_NOCOLOR;See Also C/C++ API | Categories | Notifications