When users are allowed to reorder columns (see Column Reordering), they may see the columns in an order other than the order in which the application defined them. An application always uses "real" column numbers in function calls. A column which was defined as column 0 using SetColumns always remains column 0 for the application, even if the column order has been changed and the column is no longer the first column displayed. This simplifies the application's logic as it can assume that column numbers never change.
The position at which a column is currently displayed is referred to as its "display" column number. Display column 0 is the leftmost column. Functions such as SetText, GetText, SetHeader, MakeColumnOptimal and FindString and structures such as SFTBOX_CELLINFOPARM use real column numbers. Display column numbers are only needed when an application wants to know the order in which the columns are shown, for example to save the column order.
The display column number of a real column is returned by GetDisplayColumn. It is also available in the dispPos member of the column's SFTBOX_COLUMN structure, returned by GetColumns. In this example, the real column number of the third column is translated to its display column number:
C
displayPosition = SftBox_GetDisplayColumn(hwndBox, 2);or
LPSFTBOX_COLUMN lpCol; int nCols, displayPosition; nCols = SftBox_GetColumns(hwndBox, &lpCol); /* Get column attributes */ displayPosition = lpCol[2].dispPos; /* Extract the display position */
C++
displayPosition = m_Box.GetDisplayColumn(2);The real column number of a display column is returned by GetRealColumn. It is also available in the column information returned by GetColumns. Please note that even though GetColumns returns an array of SFTBOX_COLUMN structures in real column order, the realPos member is retrieved using a display column number as array index. In this example, the display column number of the second displayed column is translated to its real column number:
C
realPosition = SftBox_GetRealColumn(hwndBox, 1);or
LPSFTBOX_COLUMN lpCol; int nCols, realPosition; nCols = SftBox_GetColumns(hwndBox, &lpCol); /* Get column attributes */ realPosition = lpCol[1].realPos; /* Extract the real position */
C++
realPosition = m_Box.GetRealColumn(1);GetFirstDisplayColumn returns the display column number of the first column that is visible. Columns with a width of 0 are not considered.
int dispCol = SftBox_GetFirstDisplayColumn(hwndBox); int realCol = SftBox_GetRealColumn(hwndBox, dispCol); /* use this column number for SftBox_GetText, etc. */
The realPos member of the SFTBOX_COLUMN structure is maintained by the combo box and is ignored by SetColumns. The dispPos member can be set by the application to define the display position of each column. Each display position (0 to the number of columns minus 1) must be used by exactly one column, otherwise the columns are displayed in the order in which they are defined.