static int fill_drives_list(HWND dialog) { int count = 0; BOOL drivec_present = FALSE; int i; int prevsel = -1; WINE_TRACE("\n"); updating_ui = TRUE; prevsel = lv_get_curr_select(dialog); /* Clear the listbox */ SendDlgItemMessage(dialog, IDC_LIST_DRIVES, LVM_DELETEALLITEMS, 0, 0); for(i = 0; i < 26; i++) { LVITEM item; char letter[4]; /* skip over any unused drives */ if (!drives[i].in_use) continue; if (drives[i].letter == 'C') drivec_present = TRUE; letter[0] = 'A' + i; letter[1] = ':'; letter[2] = 0; item.mask = LVIF_TEXT | LVIF_PARAM; item.iItem = count; item.iSubItem = 0; item.pszText = letter; item.cchTextMax = lstrlen(item.pszText); item.lParam = (LPARAM) &drives[i]; lv_insert_item(dialog, &item); lv_set_item_text(dialog, count, 1, drives[i].unixpath); count++; } WINE_TRACE("loaded %d drives\n", count); /* show the warning if there is no Drive C */ if (!drivec_present) ShowWindow(GetDlgItem(dialog, IDS_DRIVE_NO_C), SW_NORMAL); else ShowWindow(GetDlgItem(dialog, IDS_DRIVE_NO_C), SW_HIDE); lv_set_curr_select(dialog, prevsel == -1 ? 0 : prevsel); updating_ui = FALSE; return count; }
LRESULT lv_insert_item_text(HWND hwnd, int row, const TCHAR *txt) { LVITEM lvi = {0}; assert(txt); if (!txt) return -1; /* means failure */ lvi.mask = LVIF_TEXT; lvi.pszText = (LPTSTR)txt; return lv_insert_item(hwnd, row, &lvi); }