1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
// InitListViewColumns - adds columns to a list-view control.
// Returns TRUE if successful, or FALSE otherwise.
// hWndListView - handle to the list-view control.
BOOL InitListViewColumns(HWND hWndListView)
{
char szText[256]; // temporary buffer
LVCOLUMN lvc;
int iCol;
// Initialize the LVCOLUMN structure.
// The mask specifies that the format, width, text, and subitem
// members of the structure are valid.
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
// Add the columns.
for (iCol = 0; iCol < C_COLUMNS; iCol++)
{
lvc.iSubItem = iCol;
lvc.pszText = szText;
lvc.cx = 100; // width of column in pixels
if ( iCol < 2 )
{
lvc.fmt = LVCFMT_LEFT; // left-aligned column
}
else
{
lvc.fmt = LVCFMT_RIGHT; // right-aligned column
}
LoadString(hInst, IDS_FIRSTCOLUMN + iCol,
szText, sizeof(szText));
if (ListView_InsertColumn(hWndListView, iCol, &lvc) == -1)
return FALSE;
}
return TRUE;
} |