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

[ui] fix notification dialog messages being truncated

* We now auto resize the height of the Notification dialog according to the
  number of lines of the message.
* Also harmonize local RECT variable names according to what we do elsewhere.
This commit is contained in:
Pete Batard 2018-06-08 13:02:39 +01:00
parent 645184f11e
commit d6e6f46029
4 changed files with 61 additions and 43 deletions

View file

@ -781,7 +781,7 @@ out:
INT_PTR CALLBACK ChecksumCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
int i, dw, dh;
RECT rect;
RECT rc;
HFONT hFont;
HDC hDC;
@ -804,18 +804,18 @@ INT_PTR CALLBACK ChecksumCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM
hDC = GetDC(GetDlgItem(hDlg, IDC_MD5));
SelectFont(hDC, hFont); // Yes, you *MUST* reapply the font to the DC, even after SetWindowText!
GetWindowRect(GetDlgItem(hDlg, IDC_MD5), &rect);
dw = rect.right - rect.left;
dh = rect.bottom - rect.top;
DrawTextU(hDC, sum_str[0], -1, &rect, DT_CALCRECT);
dw = rect.right - rect.left - dw + 12; // Ideally we'd compute the field borders from the system, but hey...
dh = rect.bottom - rect.top - dh + 6;
GetWindowRect(GetDlgItem(hDlg, IDC_MD5), &rc);
dw = rc.right - rc.left;
dh = rc.bottom - rc.top;
DrawTextU(hDC, sum_str[0], -1, &rc, DT_CALCRECT);
dw = rc.right - rc.left - dw + 12; // Ideally we'd compute the field borders from the system, but hey...
dh = rc.bottom - rc.top - dh + 6;
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDC_SHA256), 0, 0, dw, dh, 1.0f);
GetWindowRect(GetDlgItem(hDlg, IDC_SHA1), &rect);
dw = rect.right - rect.left;
DrawTextU(hDC, sum_str[1], -1, &rect, DT_CALCRECT);
dw = rect.right - rect.left - dw + 12;
GetWindowRect(GetDlgItem(hDlg, IDC_SHA1), &rc);
dw = rc.right - rc.left;
DrawTextU(hDC, sum_str[1], -1, &rc, DT_CALCRECT);
dw = rc.right - rc.left - dw + 12;
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDC_MD5), 0, 0, dw, 0, 1.0f);
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDC_SHA1), 0, 0, dw, 0, 1.0f);
ResizeButtonHeight(hDlg, IDOK);

View file

@ -2972,7 +2972,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
case WM_COMMAND:
#ifdef RUFUS_TEST
if (LOWORD(wParam) == IDC_TEST) {
ToggleImageSettings("blah.iso");
Notification(MSG_ERROR, NULL, lmprintf(MSG_042), lmprintf(MSG_043, lmprintf(MSG_055)));
break;
}
#endif

View file

@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 232, 326
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_ACCEPTFILES
CAPTION "Rufus 3.1.1312"
CAPTION "Rufus 3.1.1313"
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
@ -126,18 +126,18 @@ BEGIN
DEFPUSHBUTTON "Close",IDCANCEL,306,305,50,12
END
IDD_NOTIFICATION DIALOGEX 0, 0, 263, 63
IDD_NOTIFICATION DIALOGEX 0, 0, 263, 59
STYLE DS_SETFONT | DS_NOFAILCREATE | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_THICKFRAME
CAPTION "Rufus"
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "",IDC_NOTIFICATION_LINE,0,0,263,39
LTEXT "",IDC_STATIC,0,0,263,38
LTEXT "",IDC_NOTIFICATION_LINE,0,0,263,35
LTEXT "",IDC_STATIC,0,0,263,34
ICON OCR_UP,IDC_NOTIFICATION_ICON,6,6,20,20
LTEXT "Message",IDC_NOTIFICATION_TEXT,35,10,219,20
DEFPUSHBUTTON "No",IDNO,206,44,50,14
PUSHBUTTON "More information",IDC_MORE_INFO,8,44,76,14,NOT WS_VISIBLE
PUSHBUTTON "Yes",IDYES,149,44,50,14,NOT WS_VISIBLE
LTEXT "Message",IDC_NOTIFICATION_TEXT,35,6,219,20
DEFPUSHBUTTON "No",IDNO,206,40,50,14
PUSHBUTTON "More information",IDC_MORE_INFO,8,40,76,14,NOT WS_VISIBLE
PUSHBUTTON "Yes",IDYES,149,40,50,14,NOT WS_VISIBLE
END
IDD_SELECTION DIALOGEX 0, 0, 312, 71
@ -389,8 +389,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,1,1312,0
PRODUCTVERSION 3,1,1312,0
FILEVERSION 3,1,1313,0
PRODUCTVERSION 3,1,1313,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -407,13 +407,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "3.1.1312"
VALUE "FileVersion", "3.1.1313"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2018 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "3.1.1312"
VALUE "ProductVersion", "3.1.1313"
END
END
BLOCK "VarFileInfo"

View file

@ -648,7 +648,7 @@ INT_PTR CreateAboutBox(void)
INT_PTR CALLBACK NotificationCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
LRESULT loc;
int i;
int i, dh;
// Prevent resizing
static LRESULT disabled[9] = { HTLEFT, HTRIGHT, HTTOP, HTBOTTOM, HTSIZE,
HTTOPLEFT, HTTOPRIGHT, HTBOTTOMLEFT, HTBOTTOMRIGHT };
@ -658,6 +658,7 @@ INT_PTR CALLBACK NotificationCallback(HWND hDlg, UINT message, WPARAM wParam, LP
HFONT hDlgFont;
HWND hCtrl;
RECT rc;
HDC hDC;
switch (message) {
case WM_INITDIALOG:
@ -710,9 +711,26 @@ INT_PTR CALLBACK NotificationCallback(HWND hDlg, UINT message, WPARAM wParam, LP
max(rc.right - rc.left, GetTextSize(hCtrl, NULL).cx + cbw), rc.bottom - rc.top, SWP_NOZORDER);
ShowWindow(hCtrl, SW_SHOW);
}
// Set the control text
// Set the control text and resize the dialog if needed
if (szMessageText != NULL) {
SetWindowTextU(GetDlgItem(hDlg, IDC_NOTIFICATION_TEXT), szMessageText);
hCtrl = GetDlgItem(hDlg, IDC_NOTIFICATION_TEXT);
SetWindowTextU(hCtrl, szMessageText);
hDC = GetDC(hCtrl);
SelectFont(hDC, hDlgFont); // Yes, you *MUST* reapply the font to the DC, even after SetWindowText!
GetWindowRect(hCtrl, &rc);
dh = rc.bottom - rc.top;
DrawTextU(hDC, szMessageText, -1, &rc, DT_CALCRECT | DT_WORDBREAK);
dh = rc.bottom - rc.top - dh + (int)(8.0f * fScale);
safe_release_dc(hCtrl, hDC);
if (dh > 0) {
ResizeMoveCtrl(hDlg, hCtrl, 0, 0, 0, dh, 1.0f);
ResizeMoveCtrl(hDlg, hDlg, 0, 0, 0, dh, 1.0f);
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, -1), 0, 0, 0, dh, 1.0f); // IDC_STATIC = -1
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDC_SELECTION_LINE), 0, dh, 0, 0, 1.0f);
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDC_MORE_INFO), 0, dh, 0, 0, 1.0f);
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDYES), 0, dh, 0, 0, 1.0f);
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDNO), 0, dh, 0, 0, 1.0f);
}
}
return (INT_PTR)TRUE;
case WM_CTLCOLORSTATIC:
@ -808,7 +826,7 @@ INT_PTR CALLBACK SelectionCallback(HWND hDlg, UINT message, WPARAM wParam, LPARA
static HBRUSH background_brush, separator_brush;
// To use the system message font
NONCLIENTMETRICS ncm;
RECT rect, rect2;
RECT rc, rc2;
HFONT hDlgFont;
HWND hCtrl;
HDC hDC;
@ -851,18 +869,18 @@ INT_PTR CALLBACK SelectionCallback(HWND hDlg, UINT message, WPARAM wParam, LPARA
hCtrl = GetDlgItem(hDlg, IDC_SELECTION_TEXT);
hDC = GetDC(hCtrl);
SelectFont(hDC, hDlgFont); // Yes, you *MUST* reapply the font to the DC, even after SetWindowText!
GetWindowRect(hCtrl, &rect);
dh = rect.bottom - rect.top;
DrawTextU(hDC, szMessageText, -1, &rect, DT_CALCRECT | DT_WORDBREAK);
dh = rect.bottom - rect.top - dh;
GetWindowRect(hCtrl, &rc);
dh = rc.bottom - rc.top;
DrawTextU(hDC, szMessageText, -1, &rc, DT_CALCRECT | DT_WORDBREAK);
dh = rc.bottom - rc.top - dh;
safe_release_dc(hCtrl, hDC);
ResizeMoveCtrl(hDlg, hCtrl, 0, 0, 0, dh, 1.0f);
for (i = 0; i < nDialogItems; i++)
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDC_SELECTION_CHOICE1 + i), 0, dh, 0, 0, 1.0f);
if (nDialogItems > 2) {
GetWindowRect(GetDlgItem(hDlg, IDC_SELECTION_CHOICE2), &rect);
GetWindowRect(GetDlgItem(hDlg, IDC_SELECTION_CHOICE1 + nDialogItems - 1), &rect2);
dh += rect2.top - rect.top;
GetWindowRect(GetDlgItem(hDlg, IDC_SELECTION_CHOICE2), &rc);
GetWindowRect(GetDlgItem(hDlg, IDC_SELECTION_CHOICE1 + nDialogItems - 1), &rc2);
dh += rc2.top - rc.top;
}
ResizeMoveCtrl(hDlg, hDlg, 0, 0, 0, dh, 1.0f);
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, -1), 0, 0, 0, dh, 1.0f); // IDC_STATIC = -1
@ -941,7 +959,7 @@ INT_PTR CALLBACK ListCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa
static HBRUSH background_brush, separator_brush;
// To use the system message font
NONCLIENTMETRICS ncm;
RECT rect, rect2;
RECT rc, rc2;
HFONT hDlgFont;
HWND hCtrl;
HDC hDC;
@ -984,18 +1002,18 @@ INT_PTR CALLBACK ListCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa
hCtrl = GetDlgItem(hDlg, IDC_LIST_TEXT);
hDC = GetDC(hCtrl);
SelectFont(hDC, hDlgFont); // Yes, you *MUST* reapply the font to the DC, even after SetWindowText!
GetWindowRect(hCtrl, &rect);
dh = rect.bottom - rect.top;
DrawTextU(hDC, szMessageText, -1, &rect, DT_CALCRECT | DT_WORDBREAK);
dh = rect.bottom - rect.top - dh;
GetWindowRect(hCtrl, &rc);
dh = rc.bottom - rc.top;
DrawTextU(hDC, szMessageText, -1, &rc, DT_CALCRECT | DT_WORDBREAK);
dh = rc.bottom - rc.top - dh;
safe_release_dc(hCtrl, hDC);
ResizeMoveCtrl(hDlg, hCtrl, 0, 0, 0, dh, 1.0f);
for (i = 0; i < nDialogItems; i++)
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, IDC_LIST_ITEM1 + i), 0, dh, 0, 0, 1.0f);
if (nDialogItems > 1) {
GetWindowRect(GetDlgItem(hDlg, IDC_LIST_ITEM1), &rect);
GetWindowRect(GetDlgItem(hDlg, IDC_LIST_ITEM1 + nDialogItems - 1), &rect2);
dh += rect2.top - rect.top;
GetWindowRect(GetDlgItem(hDlg, IDC_LIST_ITEM1), &rc);
GetWindowRect(GetDlgItem(hDlg, IDC_LIST_ITEM1 + nDialogItems - 1), &rc2);
dh += rc2.top - rc.top;
}
ResizeMoveCtrl(hDlg, hDlg, 0, 0, 0, dh, 1.0f);
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, -1), 0, 0, 0, dh, 1.0f); // IDC_STATIC = -1