1
1
Fork 0
mirror of https://github.com/pbatard/rufus.git synced 2024-08-14 23:57:05 +00:00

[enum] populate properties on initialization and selection

This commit is contained in:
Pete Batard 2011-11-18 23:41:28 +00:00
parent 4bf87001ec
commit 0b97a79de2

View file

@ -40,8 +40,8 @@
/* /*
* Globals * Globals
*/ */
static HINSTANCE main_instance; static HINSTANCE hMainInstance;
static HWND hDeviceList, hCapacity; static HWND hDialog, hDeviceList, hCapacity;
#ifdef USBDOS_DEBUG #ifdef USBDOS_DEBUG
static void _uprintf(const char *format, ...) static void _uprintf(const char *format, ...)
@ -214,6 +214,11 @@ static BOOL PopulateProperties(int index)
char* suffix[] = { "KB", "MB", "GB", "TB", "PB"}; char* suffix[] = { "KB", "MB", "GB", "TB", "PB"};
int i; int i;
IGNORE_RETVAL(ComboBox_ResetContent(hCapacity));
if (index < 0) {
return TRUE;
}
DeviceNumber = (DWORD)ComboBox_GetItemData(hDeviceList, index); DeviceNumber = (DWORD)ComboBox_GetItemData(hDeviceList, index);
if (!GetDriveInfo(DeviceNumber, &DiskSize)) if (!GetDriveInfo(DeviceNumber, &DiskSize))
return FALSE; return FALSE;
@ -226,7 +231,6 @@ static BOOL PopulateProperties(int index)
break; break;
} }
} }
IGNORE_RETVAL(ComboBox_ResetContent(hCapacity));
IGNORE_RETVAL(ComboBox_AddStringU(hCapacity, capacity)); IGNORE_RETVAL(ComboBox_AddStringU(hCapacity, capacity));
IGNORE_RETVAL(ComboBox_SetCurSel(hCapacity, 0)); IGNORE_RETVAL(ComboBox_SetCurSel(hCapacity, 0));
return TRUE; return TRUE;
@ -328,7 +332,8 @@ static BOOL GetUSBDevices(void)
} }
} }
IGNORE_RETVAL(ComboBox_SetCurSel(hDeviceList, 0)); IGNORE_RETVAL(ComboBox_SetCurSel(hDeviceList, 0));
PopulateProperties(0); PostMessage(hDialog, WM_COMMAND, (CBN_SELCHANGE<<16) | IDC_DEVICE, 0);
return TRUE; return TRUE;
} }
@ -346,6 +351,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
return (INT_PTR)TRUE; return (INT_PTR)TRUE;
case WM_INITDIALOG: case WM_INITDIALOG:
hDialog = hDlg;
hDeviceList = GetDlgItem(hDlg, IDC_DEVICE); hDeviceList = GetDlgItem(hDlg, IDC_DEVICE);
hCapacity = GetDlgItem(hDlg, IDC_CAPACITY); hCapacity = GetDlgItem(hDlg, IDC_CAPACITY);
GetUSBDevices(); GetUSBDevices();
@ -353,6 +359,13 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
case WM_COMMAND: case WM_COMMAND:
switch(LOWORD(wParam)) { switch(LOWORD(wParam)) {
case IDC_DEVICE: // dropdown: device description
switch (HIWORD(wParam)) {
case CBN_SELCHANGE:
PopulateProperties(ComboBox_GetCurSel(hDeviceList));
break;
}
break;
case IDC_CLOSE: case IDC_CLOSE:
PostQuitMessage(0); PostQuitMessage(0);
break; break;
@ -430,7 +443,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
} }
// Save instance of the application for further reference // Save instance of the application for further reference
main_instance = hInstance; hMainInstance = hInstance;
// Initialize COM for folder selection // Initialize COM for folder selection
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);