mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
[ui] added FS selection and tooltip
This commit is contained in:
parent
4f3ebdf92c
commit
f661e5c585
4 changed files with 42 additions and 12 deletions
39
rufus.c
39
rufus.c
|
@ -72,7 +72,8 @@ struct {
|
|||
char FSType[32];
|
||||
} SelectedDrive;
|
||||
|
||||
static HWND hDeviceList, hCapacity, hFileSystem, hLabel, hDeviceToolTip = NULL;
|
||||
static HWND hDeviceList, hCapacity, hFileSystem, hLabel;
|
||||
static HWND hDeviceTooltip = NULL, hFSTooltip = NULL;
|
||||
static StrArray DriveID, DriveLabel;
|
||||
|
||||
#ifdef RUFUS_DEBUG
|
||||
|
@ -315,7 +316,7 @@ static BOOL GetDriveInfo(void)
|
|||
void* drive_layout = (void*)layout;
|
||||
PDISK_GEOMETRY_EX DiskGeometry = (PDISK_GEOMETRY_EX)disk_geometry;
|
||||
PDRIVE_LAYOUT_INFORMATION_EX DriveLayout = (PDRIVE_LAYOUT_INFORMATION_EX)drive_layout;
|
||||
char DrivePath[] = "#:\\";
|
||||
char DrivePath[] = "#:\\", tmp[128];
|
||||
DWORD i, nb_partitions = 0;
|
||||
|
||||
SelectedDrive.DiskSize = 0;
|
||||
|
@ -340,11 +341,19 @@ static BOOL GetDriveInfo(void)
|
|||
if (!r || size <= 0) {
|
||||
uprintf("IOCTL_DISK_GET_DRIVE_LAYOUT_EX failed: %s\n", WindowsErrorString());
|
||||
} else {
|
||||
DestroyTooltip(hFSTooltip);
|
||||
hFSTooltip = NULL;
|
||||
switch (DriveLayout->PartitionStyle) {
|
||||
case PARTITION_STYLE_MBR:
|
||||
for (i=0; i<DriveLayout->PartitionCount; i++) {
|
||||
if (DriveLayout->PartitionEntry[i].Mbr.PartitionType != PARTITION_ENTRY_UNUSED) {
|
||||
uprintf("Partition #%d:\n", ++nb_partitions);
|
||||
if (hFSTooltip == NULL) {
|
||||
safe_sprintf(tmp, sizeof(tmp), "Existing file system: %s (0x%02X)",
|
||||
GetPartitionType(DriveLayout->PartitionEntry[i].Mbr.PartitionType),
|
||||
DriveLayout->PartitionEntry[i].Mbr.PartitionType);
|
||||
hFSTooltip = CreateTooltip(hFileSystem, tmp, -1);
|
||||
}
|
||||
uprintf(" Type: %s (0x%02X)\n Boot: %s\n Recognized: %s\n Hidden Sectors: %d\n",
|
||||
GetPartitionType(DriveLayout->PartitionEntry[i].Mbr.PartitionType),
|
||||
DriveLayout->PartitionEntry[i].Mbr.PartitionType,
|
||||
|
@ -366,9 +375,18 @@ static BOOL GetDriveInfo(void)
|
|||
|
||||
safe_closehandle(hDrive);
|
||||
|
||||
if (!GetVolumeInformationA(DrivePath, NULL, 0, NULL, NULL, NULL,
|
||||
IGNORE_RETVAL(ComboBox_SetCurSel(hFileSystem, FS_DEFAULT));
|
||||
if (GetVolumeInformationA(DrivePath, NULL, 0, NULL, NULL, NULL,
|
||||
SelectedDrive.FSType, sizeof(SelectedDrive.FSType))) {
|
||||
safe_sprintf(SelectedDrive.FSType, sizeof(SelectedDrive.FSType), "Non Windows (Please Select)");
|
||||
// re-select existing FS if it's one we know
|
||||
for (i=0; i<FS_MAX; i++) {
|
||||
tmp[0] = 0;
|
||||
IGNORE_RETVAL(ComboBox_GetLBTextU(hFileSystem, i, tmp));
|
||||
if (safe_strcmp(SelectedDrive.FSType, tmp) == 0) {
|
||||
IGNORE_RETVAL(ComboBox_SetCurSel(hFileSystem, i));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
@ -388,14 +406,19 @@ static BOOL PopulateProperties(int ComboIndex)
|
|||
IGNORE_RETVAL(ComboBox_ResetContent(hCapacity));
|
||||
IGNORE_RETVAL(ComboBox_ResetContent(hFileSystem));
|
||||
SetWindowTextA(hLabel, "");
|
||||
DestroyTooltip(hDeviceToolTip);
|
||||
hDeviceToolTip = NULL;
|
||||
DestroyTooltip(hDeviceTooltip);
|
||||
hDeviceTooltip = NULL;
|
||||
memset(&SelectedDrive, 0, sizeof(SelectedDrive));
|
||||
|
||||
if (ComboIndex < 0) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Populate the FileSystem values
|
||||
IGNORE_RETVAL(ComboBox_AddStringU(hFileSystem, "FAT"));
|
||||
IGNORE_RETVAL(ComboBox_AddStringU(hFileSystem, "FAT32"));
|
||||
IGNORE_RETVAL(ComboBox_AddStringU(hFileSystem, "NTFS"));
|
||||
|
||||
SelectedDrive.DeviceNumber = (DWORD)ComboBox_GetItemData(hDeviceList, ComboIndex);
|
||||
if (!GetDriveInfo())
|
||||
return FALSE;
|
||||
|
@ -410,9 +433,7 @@ static BOOL PopulateProperties(int ComboIndex)
|
|||
}
|
||||
IGNORE_RETVAL(ComboBox_AddStringU(hCapacity, capacity));
|
||||
IGNORE_RETVAL(ComboBox_SetCurSel(hCapacity, 0));
|
||||
IGNORE_RETVAL(ComboBox_AddStringU(hFileSystem, SelectedDrive.FSType));
|
||||
IGNORE_RETVAL(ComboBox_SetCurSel(hFileSystem, 0));
|
||||
hDeviceToolTip = CreateTooltip(hDeviceList, DriveID.Table[ComboIndex], -1);
|
||||
hDeviceTooltip = CreateTooltip(hDeviceList, DriveID.Table[ComboIndex], -1);
|
||||
|
||||
// If no existing label is available, propose one according to the size (eg: "256MB", "8GB")
|
||||
if (safe_strcmp(no_label, DriveLabel.Table[ComboIndex]) == 0) {
|
||||
|
|
11
rufus.h
11
rufus.h
|
@ -27,6 +27,7 @@
|
|||
#define MAX_DRIVES 16
|
||||
#define MAX_TOOLTIPS 16
|
||||
#define PROPOSEDLABEL_TOLERANCE 0.10
|
||||
#define FS_DEFAULT FS_FAT32
|
||||
#define WHITE RGB(255,255,255)
|
||||
#define SEPARATOR_GREY RGB(223,223,223)
|
||||
#define RUFUS_URL "https://github.com/pbatard/rufus/wiki/Rufus"
|
||||
|
@ -73,7 +74,7 @@ extern char *WindowsErrorString(void);
|
|||
extern void CenterDialog(HWND hDlg);
|
||||
extern void CreateStatusBar(void);
|
||||
extern INT_PTR CreateAboutBox(void);
|
||||
extern HWND CreateTooltip(HWND hControl, char* message, int duration);
|
||||
extern HWND CreateTooltip(HWND hControl, const char* message, int duration);
|
||||
extern void DestroyTooltip(HWND hWnd);
|
||||
extern void DestroyAllTooltips(void);
|
||||
extern void Notification(int type, char* text, char* title);
|
||||
|
@ -104,6 +105,14 @@ enum MessageType {
|
|||
MSG_ERROR
|
||||
};
|
||||
|
||||
/* File system indexes in our FS combobox */
|
||||
enum FSType {
|
||||
FS_FAT16 = 0,
|
||||
FS_FAT32,
|
||||
FS_NTFS,
|
||||
FS_MAX
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
DWORD DeviceType;
|
||||
ULONG DeviceNumber;
|
||||
|
|
2
rufus.rc
2
rufus.rc
|
@ -37,7 +37,7 @@ BEGIN
|
|||
PUSHBUTTON "Close",IDCANCEL,156,224,50,14
|
||||
COMBOBOX IDC_DEVICE,16,18,190,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
CONTROL "&Device",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,17,7,22,8
|
||||
COMBOBOX IDC_FILESYSTEM,16,76,190,30,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
|
||||
COMBOBOX IDC_FILESYSTEM,16,76,190,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "&File system",IDC_STATIC,17,65,51,10
|
||||
COMBOBOX IDC_CAPACITY,16,47,190,30,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "Ca&pacity",IDC_STATIC,17,36,29,8
|
||||
|
|
2
stdlg.c
2
stdlg.c
|
@ -619,7 +619,7 @@ INT_PTR CALLBACK TooltipCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM
|
|||
* duration sets the duration in ms. Use -1 for default
|
||||
* message is an UTF-8 string
|
||||
*/
|
||||
HWND CreateTooltip(HWND hControl, char* message, int duration)
|
||||
HWND CreateTooltip(HWND hControl, const char* message, int duration)
|
||||
{
|
||||
TOOLINFOW toolInfo = {0};
|
||||
int i;
|
||||
|
|
Loading…
Reference in a new issue