00 Add List-View Columns

Post date: 2012/4/5 上午 01:18:00

BOOL InitListViewColumns(HWND hWndListView) { WCHAR szText[256]; // Temporary buffer. LVCOLUMN lvc; int iCol = 0; lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; lvc.iSubItem = iCol; lvc.pszText = L"check"; lvc.cchTextMax=9; lvc.cx = 50; // Width of column in pixels. lvc.fmt = LVCFMT_LEFT; if (ListView_InsertColumn(hProgramView, iCol, &lvc) == -1) return FALSE; lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; iCol = 1; lvc.iSubItem = iCol; lvc.pszText = L"Software"; lvc.cchTextMax=9; lvc.cx = 200; // Width of column in pixels. lvc.fmt = LVCFMT_LEFT; if (ListView_InsertColumn(hWndListView, iCol, &lvc) == -1) return FALSE; /* // Add the columns. for (iCol = 0; iCol < 2; iCol++) { lvc.iSubItem = iCol; lvc.pszText = L"haha ha "; lvc.cchTextMax=9; lvc.cx = 60; // Width of column in pixels. if ( iCol < 2 ) lvc.fmt = LVCFMT_LEFT; // Left-aligned column. else lvc.fmt = LVCFMT_RIGHT; // Right-aligned column. // Load the names of the column headings from the string resources. LoadString(hinst, IDS_FIRSTCOLUMN + iCol, szText, sizeof(szText)/sizeof(szText[0])); // Insert the columns into the list view. if (ListView_InsertColumn(hWndListView, iCol, &lvc) == -1) return FALSE; } */ return TRUE; }