void BarListWindow::OnCreate(void) { hwndList = CreateWindow(WC_LISTVIEW, NULL, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, hWnd, NULL, GetModuleHandle(NULL), NULL); ListView_SetExtendedListViewStyle(hwndList, LVS_EX_DOUBLEBUFFER); ListView_SetView(hwndList, LV_VIEW_TILE);
HMODULE hShell = LoadLibrary(TEXT("shell32.dll")); int iIcons[] = {5}; int n = sizeof(iIcons) / sizeof(int); int i; himlBig = ImageList_Create(48, 48, ILC_COLOR32, 0, 1); himlSmall = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32, 0, 1); ListView_SetImageList(hwndList, himlBig, LVSIL_NORMAL); ListView_SetImageList(hwndList, himlSmall, LVSIL_SMALL); for (i = 0; i < n; i++) { HICON hIcon = LoadIcon(hShell, MAKEINTRESOURCE(iIcons[i])); ImageList_AddIcon(himlBig, hIcon); ImageList_AddIcon(himlSmall, hIcon); DestroyIcon(hIcon); } FreeLibrary(hShell);
LVCOLUMN lvc; lvc.mask = LVCF_TEXT | LVCF_WIDTH; lvc.cx = 300; lvc.pszText = TEXT("侃吧名称"); ListView_InsertColumn(hwndList, 0, &lvc); lvc.cx = 150; lvc.pszText = TEXT("简介"); ListView_InsertColumn(hwndList, 1, &lvc); lvc.cx = 150; lvc.pszText = TEXT("创建者"); ListView_InsertColumn(hwndList, 2, &lvc); lvc.cx = 150; lvc.pszText = TEXT("规模"); ListView_InsertColumn(hwndList, 3, &lvc);
LVTILEVIEWINFO lvtvinfo; lvtvinfo.cbSize = sizeof(LVTILEVIEWINFO); lvtvinfo.cLines = 2; lvtvinfo.dwMask = LVTVIM_COLUMNS; lvtvinfo.dwFlags = LVTVIF_AUTOSIZE; ListView_SetTileViewInfo(hwndList, &lvtvinfo);
UINT uColumns[] = {1, 3}; LVITEM lvi; lvi.mask = LVIF_COLUMNS | LVIF_IMAGE | LVIF_TEXT; lvi.iItem = 0; lvi.iSubItem = 0; lvi.cColumns = sizeof(uColumns) / sizeof(UINT); lvi.puColumns = uColumns; lvi.iImage = 0; lvi.pszText = TEXT("简体中文吧"); ListView_InsertItem(hwndList, &lvi);
lvi.mask = LVIF_TEXT; lvi.iSubItem = 1; lvi.pszText = TEXT("这是侃吧简介..."); ListView_SetItem(hwndList, &lvi);
lvi.iSubItem = 2; lvi.pszText = TEXT("巨大八爪鱼"); ListView_SetItem(hwndList, &lvi);
lvi.iSubItem = 3; lvi.pszText = TEXT("480个主题, 11280篇帖子"); ListView_SetItem(hwndList, &lvi); }
|