static void OnListSelection(LPFLN_ITEMSELECT_PARAMS pItemParms) { ASSERT(pItemParms); hSelectedItem = 0; if (pItemParms->hItem) { LPARAM lParam = FastList_GetItemParam(hDriveList, pItemParms->hItem); if (lParam == 0) { hSelectedItem = pItemParms->hItem; if (bAutoSetPartitionName) { LPCTSTR pDrive = FastList_GetItemText(hDriveList, hSelectedItem, 0); g_CfgData.szPartitionName[0] = _totlower(pDrive[0]); g_CfgData.szPartitionName[1] = 0; SetWndText(hDlg, IDC_PARTITION_NAME, g_CfgData.szPartitionName); // Must set this to true because the call to SetWndText will cause // a call to OnPartitionName, which would incorrectly think that the // Partition Name had been set by the user rather than by us, thus // setting bAutoSetPartitionName to false. bAutoSetPartitionName = TRUE; } } } CheckEnableButtons(); }
static int CALLBACK DriveListSortFunc(HWND hList, HLISTITEM hItem1, LPARAM lpItem1, HLISTITEM hItem2, LPARAM lpItem2) { _ASSERTE(hList == m_hDriveList); // Ignore the first call which is only used to initialize static data if (!hItem1 && !hItem2) return 0; // The lpItem vars contain 1 if the item is disabled, 0 if not // Show enabled items before disabled items if (lpItem1 != lpItem2) return lpItem1 - lpItem2; LPCTSTR pszItem1 = FastList_GetItemText(m_hDriveList, hItem1, 0); LPCTSTR pszItem2 = FastList_GetItemText(m_hDriveList, hItem2, 0); return lstrcmp(pszItem1, pszItem2); }
void Browse_OnSelect (HWND hDlg) { LPBROWSE_PARAMS lpp; if ((lpp = (LPBROWSE_PARAMS)GetWindowLongPtr (hDlg, DWLP_USER)) != NULL) { if (!lpp->fQuerying) { HWND hList = GetDlgItem (hDlg, IDC_BROWSE_LIST); static TCHAR szSeparator[ cchRESOURCE ] = TEXT(""); if (szSeparator[0] == TEXT('\0')) { if (!GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_SLIST, szSeparator, cchRESOURCE)) lstrcpy (szSeparator, TEXT(",")); lstrcat (szSeparator, TEXT(" ")); } LPTSTR pszText = NULL; HLISTITEM hItem = NULL; while ((hItem = FastList_FindNextSelected (hList, hItem)) != NULL) { LPCTSTR pszName; if ((pszName = FastList_GetItemText (hList, hItem, 0)) != NULL) { LPTSTR pszNew; if (pszText) pszNew = FormatString (TEXT("%1%2%3"), TEXT("%s%s%s"), pszText, szSeparator, pszName); else pszNew = FormatString (TEXT("%1"), TEXT("%s"), pszName); if (pszText) FreeString (pszText); pszText = pszNew; } if (pszText && !lpp->fAllowMultiple) break; } SetDlgItemText (hDlg, IDC_BROWSE_NAMED, (pszText) ? pszText : TEXT("")); if (pszText) FreeString (pszText); } } }
DRIVEMAP *GetSelectedDrive(HWND hDlg, HLISTITEM *pItem) { static DRIVEMAP DriveMap; HLISTITEM hItem; HWND hList = GetDlgItem (hDlg, IDC_GLOBAL_DRIVE_LIST); if (!pItem) pItem = &hItem; if ((*pItem = FastList_FindFirstSelected (hList)) == NULL) return 0; LPCTSTR pszDrive = FastList_GetItemText (hList, *pItem, 0); int nCurDrive = pszDrive[DRIVE_LETTER_INDEX] - TEXT('A'); memcpy(&DriveMap, &GlobalDrives.aDriveMap[nCurDrive], sizeof(DRIVEMAP)); return &DriveMap; }
static void ShowPartitionInfo() { // The SetWndText call below will mess up our bAutoSetPartitionName variable. // It will trigger the change event on the partition name field causing our // OnPartitionName function to get called, and making it look to us like the // user set the partition name. Therefore, we will save the current value, // make the call, then restore the value. BOOL bAutoSet = bAutoSetPartitionName; SetWndText(hDlg, IDC_PARTITION_NAME, g_CfgData.szPartitionName); bAutoSetPartitionName = bAutoSet; if (g_CfgData.chDeviceName != 0) { HLISTITEM hItem = NULL; while ((hItem = FastList_FindNext(hDriveList, hItem)) != NULL) { LPCTSTR pDrive = FastList_GetItemText(hDriveList, hItem, 0); if (pDrive[0] == g_CfgData.chDeviceName) { FastList_SelectItem(hDriveList, hItem, TRUE); hSelectedItem = hItem; break; } } } }
static BOOL SavePartitionInfo(BOOL bValidate) { if (bCantCreate) return TRUE; if (GetButtonState(hDlg, IDC_CREATE_PARTITION) != BST_CHECKED) { g_CfgData.szPartitionName[0] = 0; bAutoSetPartitionName = TRUE; } else { GetWindowText(GetDlgItem(hDlg, IDC_PARTITION_NAME), g_CfgData.szPartitionName, MAX_PARTITION_NAME_LEN); if (bValidate && !Validation_IsValid(g_CfgData.szPartitionName, VALID_AFS_PARTITION_NAME)) return FALSE; } if (hSelectedItem == 0) g_CfgData.chDeviceName = 0; else { LPCTSTR pDrive = FastList_GetItemText(hDriveList, hSelectedItem, 0); g_CfgData.chDeviceName = pDrive[0]; } return TRUE; }