mirror of
https://github.com/pbatard/rufus.git
synced 2025-05-27 13:14:26 -04:00
[fido] improve UI handling
* Center dialog on open * Close dialog on main application exit * Display ISO short name & size on status bar during download * Display ISO download progress on taskbar * Also fix improper detection of EAGET Mass Storage USB Device as HDD
This commit is contained in:
parent
9d1a2bc25e
commit
65f886141b
9 changed files with 165 additions and 149 deletions
61
src/stdlg.c
61
src/stdlg.c
|
@ -51,8 +51,7 @@ static char* szMessageText = NULL;
|
|||
static char* szMessageTitle = NULL;
|
||||
static char **szDialogItem;
|
||||
static int nDialogItems;
|
||||
static HWND hBrowseEdit;
|
||||
extern HWND hUpdatesDlg;
|
||||
static HWND hBrowseEdit, hUpdatesDlg;
|
||||
static WNDPROC pOrgBrowseWndproc;
|
||||
static const SETTEXTEX friggin_microsoft_unicode_amateurs = {ST_DEFAULT, CP_UTF8};
|
||||
static BOOL notification_is_question;
|
||||
|
@ -60,8 +59,8 @@ static const notification_info* notification_more_info;
|
|||
static const char* notification_dont_display_setting;
|
||||
static WNDPROC update_original_proc = NULL;
|
||||
static HWINEVENTHOOK ap_weh = NULL;
|
||||
static char *fp_title_str = "Microsoft Windows", *fp_button_str = "Format disk";
|
||||
static char *cp_title_str = "Windows Security Warning";
|
||||
static char title_str[3][128], button_str[128];
|
||||
HWND hFidoDlg = NULL;
|
||||
BOOL close_fido_cookie_prompts = FALSE;
|
||||
|
||||
static int update_settings_reposition_ids[] = {
|
||||
|
@ -442,16 +441,16 @@ void CreateStatusBar(void)
|
|||
|
||||
/*
|
||||
* Center a dialog with regards to the main application Window or the desktop
|
||||
* See http://msdn.microsoft.com/en-us/library/windows/desktop/ms644996.aspx#init_box
|
||||
* See https://docs.microsoft.com/en-gb/windows/desktop/dlgbox/using-dialog-boxes#initializing-a-dialog-box
|
||||
*/
|
||||
void CenterDialog(HWND hDlg)
|
||||
void CenterDialog(HWND hDlg, HWND hParent)
|
||||
{
|
||||
HWND hParent;
|
||||
RECT rc, rcDlg, rcParent;
|
||||
|
||||
if ((hParent = GetParent(hDlg)) == NULL) {
|
||||
if (hParent == NULL)
|
||||
hParent = GetParent(hDlg);
|
||||
if (hParent == NULL)
|
||||
hParent = GetDesktopWindow();
|
||||
}
|
||||
|
||||
GetWindowRect(hParent, &rcParent);
|
||||
GetWindowRect(hDlg, &rcDlg);
|
||||
|
@ -530,7 +529,7 @@ INT_PTR CALLBACK LicenseCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM
|
|||
case WM_INITDIALOG:
|
||||
hLicense = GetDlgItem(hDlg, IDC_LICENSE_TEXT);
|
||||
apply_localization(IDD_LICENSE, hDlg);
|
||||
CenterDialog(hDlg);
|
||||
CenterDialog(hDlg, NULL);
|
||||
ResizeButtonHeight(hDlg, IDCANCEL);
|
||||
// Suppress any inherited RTL flags
|
||||
style = GetWindowLongPtr(hLicense, GWL_EXSTYLE);
|
||||
|
@ -576,7 +575,7 @@ INT_PTR CALLBACK AboutCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lP
|
|||
// Execute dialog localization
|
||||
apply_localization(IDD_ABOUTBOX, hDlg);
|
||||
SetTitleBarIcon(hDlg);
|
||||
CenterDialog(hDlg);
|
||||
CenterDialog(hDlg, NULL);
|
||||
// Resize the 'License' button
|
||||
hCtrl = GetDlgItem(hDlg, IDC_ABOUT_LICENSE);
|
||||
GetWindowRect(hCtrl, &rc);
|
||||
|
@ -704,7 +703,7 @@ INT_PTR CALLBACK NotificationCallback(HWND hDlg, UINT message, WPARAM wParam, LP
|
|||
separator_brush = CreateSolidBrush(GetSysColor(COLOR_3DLIGHT));
|
||||
buttonface_brush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
|
||||
SetTitleBarIcon(hDlg);
|
||||
CenterDialog(hDlg);
|
||||
CenterDialog(hDlg, NULL);
|
||||
// Change the default icon
|
||||
if (Static_SetIcon(GetDlgItem(hDlg, IDC_NOTIFICATION_ICON), hMessageIcon) == 0) {
|
||||
uprintf("Could not set dialog icon\n");
|
||||
|
@ -897,7 +896,7 @@ INT_PTR CALLBACK SelectionCallback(HWND hDlg, UINT message, WPARAM wParam, LPARA
|
|||
background_brush = CreateSolidBrush(GetSysColor(COLOR_WINDOW));
|
||||
separator_brush = CreateSolidBrush(GetSysColor(COLOR_3DLIGHT));
|
||||
SetTitleBarIcon(hDlg);
|
||||
CenterDialog(hDlg);
|
||||
CenterDialog(hDlg, NULL);
|
||||
// Change the default icon and set the text
|
||||
Static_SetIcon(GetDlgItem(hDlg, IDC_SELECTION_ICON), LoadIcon(NULL, IDI_QUESTION));
|
||||
SetWindowTextU(hDlg, szMessageTitle);
|
||||
|
@ -1030,7 +1029,7 @@ INT_PTR CALLBACK ListCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa
|
|||
background_brush = CreateSolidBrush(GetSysColor(COLOR_WINDOW));
|
||||
separator_brush = CreateSolidBrush(GetSysColor(COLOR_3DLIGHT));
|
||||
SetTitleBarIcon(hDlg);
|
||||
CenterDialog(hDlg);
|
||||
CenterDialog(hDlg, NULL);
|
||||
// Change the default icon and set the text
|
||||
Static_SetIcon(GetDlgItem(hDlg, IDC_LIST_ICON), LoadIcon(NULL, IDI_EXCLAMATION));
|
||||
SetWindowTextU(hDlg, szMessageTitle);
|
||||
|
@ -1413,7 +1412,7 @@ INT_PTR CALLBACK UpdateCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM l
|
|||
apply_localization(IDD_UPDATE_POLICY, hDlg);
|
||||
PositionControls(hDlg);
|
||||
SetTitleBarIcon(hDlg);
|
||||
CenterDialog(hDlg);
|
||||
CenterDialog(hDlg, NULL);
|
||||
hFrequency = GetDlgItem(hDlg, IDC_UPDATE_FREQUENCY);
|
||||
hBeta = GetDlgItem(hDlg, IDC_INCLUDE_BETAS);
|
||||
IGNORE_RETVAL(ComboBox_SetItemData(hFrequency, ComboBox_AddStringU(hFrequency, lmprintf(MSG_013)), -1));
|
||||
|
@ -1636,7 +1635,7 @@ INT_PTR CALLBACK NewVersionCallback(HWND hDlg, UINT message, WPARAM wParam, LPAR
|
|||
apply_localization(IDD_NEW_VERSION, hDlg);
|
||||
download_status = 0;
|
||||
SetTitleBarIcon(hDlg);
|
||||
CenterDialog(hDlg);
|
||||
CenterDialog(hDlg, NULL);
|
||||
// Subclass the callback so that we can change the cursor
|
||||
update_original_proc = (WNDPROC)SetWindowLongPtr(hDlg, GWLP_WNDPROC, (LONG_PTR)update_subclass_callback);
|
||||
hNotes = GetDlgItem(hDlg, IDC_RELEASE_NOTES);
|
||||
|
@ -1949,7 +1948,7 @@ static BOOL CALLBACK AlertPromptCallback(HWND hWnd, LPARAM lParam)
|
|||
|
||||
if (GetWindowTextU(hWnd, str, sizeof(str)) == 0)
|
||||
return TRUE;
|
||||
if (safe_strcmp(str, fp_button_str) == 0)
|
||||
if (safe_strcmp(str, button_str) == 0)
|
||||
*found = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -1963,15 +1962,19 @@ static void CALLBACK AlertPromptHook(HWINEVENTHOOK hWinEventHook, DWORD Event, H
|
|||
if (GetWindowLongPtr(hWnd, GWL_STYLE) & WS_POPUPWINDOW) {
|
||||
str[0] = 0;
|
||||
GetWindowTextU(hWnd, str, sizeof(str));
|
||||
if (strcmp(str, fp_title_str) == 0) {
|
||||
if (strcmp(str, title_str[0]) == 0) {
|
||||
found = FALSE;
|
||||
EnumChildWindows(hWnd, AlertPromptCallback, (LPARAM)&found);
|
||||
if (found) {
|
||||
SendMessage(hWnd, WM_COMMAND, (WPARAM)IDCANCEL, (LPARAM)0);
|
||||
uprintf("Closed Windows format prompt");
|
||||
}
|
||||
} else if (close_fido_cookie_prompts && strcmp(str, cp_title_str) == 0) {
|
||||
} else if (close_fido_cookie_prompts && strcmp(str, title_str[1]) == 0) {
|
||||
SendMessage(hWnd, WM_COMMAND, (WPARAM)IDCANCEL, (LPARAM)0);
|
||||
} else if ((strcmp(str, title_str[2]) == 0) && (hWnd != hFidoDlg)) {
|
||||
// A wild Fido dialog appeared! => Keep track of its handle and center it
|
||||
hFidoDlg = hWnd;
|
||||
CenterDialog(hWnd, hMainDialog);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1981,7 +1984,6 @@ BOOL SetAlertPromptHook(void)
|
|||
{
|
||||
HMODULE mui_lib;
|
||||
char mui_path[MAX_PATH];
|
||||
static char title_str[2][128], button_str[128];
|
||||
|
||||
if (ap_weh != NULL)
|
||||
return TRUE; // No need to set again if active
|
||||
|
@ -1993,26 +1995,27 @@ BOOL SetAlertPromptHook(void)
|
|||
// 4097 = "You need to format the disk in drive %c: before you can use it." (dialog text)
|
||||
// 4125 = "Microsoft Windows" (dialog title)
|
||||
// 4126 = "Format disk" (button)
|
||||
if (LoadStringU(mui_lib, 4125, title_str[0], sizeof(title_str[0])) > 0)
|
||||
fp_title_str = title_str[0];
|
||||
else
|
||||
if (LoadStringU(mui_lib, 4125, title_str[0], sizeof(title_str[0])) <= 0) {
|
||||
static_strcpy(title_str[0], "Microsoft Windows");
|
||||
uprintf("Warning: Could not locate localized format prompt title string in '%s': %s", mui_path, WindowsErrorString());
|
||||
if (LoadStringU(mui_lib, 4126, button_str, sizeof(button_str)) > 0)
|
||||
fp_button_str = button_str;
|
||||
else
|
||||
}
|
||||
if (LoadStringU(mui_lib, 4126, button_str, sizeof(button_str)) <= 0) {
|
||||
static_strcpy(button_str, "Format disk");
|
||||
uprintf("Warning: Could not locate localized format prompt button string in '%s': %s", mui_path, WindowsErrorString());
|
||||
}
|
||||
FreeLibrary(mui_lib);
|
||||
}
|
||||
static_sprintf(mui_path, "%s\\%s\\urlmon.dll.mui", system_dir, GetCurrentMUI());
|
||||
mui_lib = LoadLibraryU(mui_path);
|
||||
if (mui_lib != NULL) {
|
||||
// 2070 = "Windows Security Warning" (yes, that's what MS uses for a stupid cookie!)
|
||||
if (LoadStringU(mui_lib, 2070, title_str[1], sizeof(title_str[1])) > 0)
|
||||
cp_title_str = title_str[1];
|
||||
else
|
||||
if (LoadStringU(mui_lib, 2070, title_str[1], sizeof(title_str[1])) <= 0) {
|
||||
static_strcpy(title_str[1], "Windows Security Warning");
|
||||
uprintf("Warning: Could not locate localized cookie prompt title string in '%s': %s", mui_path, WindowsErrorString());
|
||||
}
|
||||
FreeLibrary(mui_lib);
|
||||
}
|
||||
static_strcpy(title_str[2], lmprintf(MSG_143));
|
||||
|
||||
ap_weh = SetWinEventHook(EVENT_SYSTEM_FOREGROUND, EVENT_SYSTEM_FOREGROUND, NULL,
|
||||
AlertPromptHook, 0, 0, WINEVENT_OUTOFCONTEXT | WINEVENT_SKIPOWNPROCESS);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue