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

[ui] add a timer on the status bar

* also ensure that the user sees a report in case too many bad blocks were found
* also changed bad blocks threshold to 256
This commit is contained in:
Pete Batard 2011-12-08 12:14:21 +00:00
parent b006e6a837
commit 4ce6a1f0f1
6 changed files with 65 additions and 18 deletions

View file

@ -281,7 +281,6 @@ static int cur_pattern, nr_pattern;
static int cur_op;
/* Abort test if more than this number of bad blocks has been encountered */
static unsigned int max_bb = EXT2_BAD_BLOCKS_THRESHOLD;
static DWORD time_start;
static blk_t currently_testing = 0;
static blk_t num_blocks = 0;
static blk_t num_read_errors = 0;
@ -357,19 +356,15 @@ static float calc_percent(unsigned long current, unsigned long total) {
static void print_status(void)
{
DWORD time_end;
float percent;
time_end = GetTickCount();
percent = calc_percent((unsigned long) currently_testing,
(unsigned long) num_blocks);
percent = (percent/2.0f) + ((cur_op==OP_READ)? 50.0f : 0.0f);
PrintStatus(0, "PASS %d/%d(%c): %6.2f%% done, %.0fs elapsed. "
"(%d/%d/%d errors)",
PrintStatus(0, "PASS %d/%d(%c): %6.2f%% done. (%d/%d/%d errors)",
cur_pattern, nr_pattern,
(cur_op==OP_READ)?'R':'W',
percent,
(time_end - time_start)/1000.0,
num_read_errors,
num_write_errors,
num_corruption_errors);
@ -964,7 +959,6 @@ BOOL BadBlocks(HANDLE hPhysicalDrive, ULONGLONG disk_size, int block_size,
test_func = test_ro;
break;
}
time_start = GetTickCount();
cancel_ops = 0;
/* use a timer to update status every second */
SetTimer(hMainDialog, BADBLOCK_TIMER_ID, 1000, alarm_intr);
@ -978,7 +972,7 @@ BOOL BadBlocks(HANDLE hPhysicalDrive, ULONGLONG disk_size, int block_size,
report->num_write_errors = num_write_errors;
report->num_corruption_errors = num_corruption_errors;
if (cancel_ops)
if ((cancel_ops) && (!report->bb_count))
return FALSE;
return TRUE;
}

View file

@ -38,7 +38,7 @@ typedef struct ext2_struct_u32_iterate *ext2_u32_iterate;
#define EXT2_CHECK_MAGIC(struct, code) \
if ((struct)->magic != (code)) return (code)
#define EXT2_BAD_BLOCKS_THRESHOLD 32
#define EXT2_BAD_BLOCKS_THRESHOLD 256
#define EXT2_BLOCKS_AT_ONCE 64
#define EXT2_SYS_PAGE_SIZE 4096

View file

@ -57,6 +57,8 @@ HWND hDeviceList, hCapacity, hFileSystem, hClusterSize, hLabel;
static HWND hDeviceTooltip = NULL, hFSTooltip = NULL;
static StrArray DriveID, DriveLabel;
static char szTimer[10] = "00:00:00";
static unsigned int timer;
/*
* Convert a partition type to its human readable form using
@ -573,6 +575,17 @@ static void EnableControls(BOOL bEnable)
SetDlgItemTextA(hMainDialog, IDCANCEL, bEnable?"Close":"Cancel");
}
/*
* Timer in the right part of the status area
*/
static void CALLBACK ClockTimer(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
{
timer++;
safe_sprintf(szTimer, sizeof(szTimer), "%02d:%02d:%02d",
timer/3600, (timer%3600)/60, timer%60);
SendMessageA(GetDlgItem(hWnd, IDC_STATUS), SB_SETTEXTA, SBT_OWNERDRAW | 1, (LPARAM)szTimer);
}
/*
* Main dialog callback
*/
@ -586,6 +599,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
{
HDC hDC;
HICON hSmallIcon, hBigIcon;
DRAWITEMSTRUCT* pDI;
int nDeviceIndex, fs;
DWORD DeviceNum;
char str[MAX_PATH], tmp[128];
@ -623,8 +637,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
hBigIcon = (HICON)LoadImage(hMainInstance, MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 32, 32, 0);
SendMessage (hDlg, WM_SETICON, ICON_BIG, (LPARAM)hBigIcon);
// Create the status line
hStatus = CreateWindowEx(0, STATUSCLASSNAME, NULL, WS_CHILD | WS_VISIBLE,
0, 0, 0, 0, hMainDialog, (HMENU)IDC_STATUS, hMainInstance, NULL);
CreateStatusBar();
// We'll switch the progressbar to marquee and back => keep a copy of current style
// ProgressStyle = GetWindowLong(hProgress, GWL_STYLE);
// Create the string array
@ -636,6 +649,19 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
GetUSBDevices();
return (INT_PTR)TRUE;
// Change the colour of the version text in the status bar
case WM_DRAWITEM:
if (wParam == IDC_STATUS) {
pDI = (DRAWITEMSTRUCT*)lParam;
SetBkMode(pDI->hDC, TRANSPARENT);
SetTextColor(pDI->hDC, GetSysColor(COLOR_3DSHADOW));
pDI->rcItem.top += (int)(2.0f * fScale);
pDI->rcItem.left += (int)(4.0f * fScale);
DrawTextExA(pDI->hDC, szTimer, -1, &pDI->rcItem, DT_LEFT, NULL);
return (INT_PTR)TRUE;
}
break;
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDOK: // close application
@ -718,6 +744,11 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|APPERR(ERROR_CANT_START_THREAD);
PostMessage(hMainDialog, UM_FORMAT_COMPLETED, 0, 0);
}
timer = 0;
safe_sprintf(szTimer, sizeof(szTimer), "00:00:00");
SendMessageA(GetDlgItem(hMainDialog, IDC_STATUS), SB_SETTEXTA,
SBT_OWNERDRAW | 1, (LPARAM)szTimer);
SetTimer(hMainDialog, STATUSBAR_TIMER_ID, 1000, ClockTimer);
}
}
break;
@ -739,6 +770,8 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
case UM_FORMAT_COMPLETED:
format_thid = -1L;
// Stop the timer
KillTimer(hMainDialog, STATUSBAR_TIMER_ID);
// Close the cancel MessageBox if active
SendMessage(FindWindowA(MAKEINTRESOURCEA(32770), RUFUS_CANCELBOX_TITLE), WM_COMMAND, IDNO, 0);
#if 0

View file

@ -85,7 +85,8 @@ enum notification_type {
/* Timers used throughout the program */
enum timer_id {
PRINTSTATUS_TIMER_ID = 0x1000,
BADBLOCK_TIMER_ID
BADBLOCK_TIMER_ID,
STATUSBAR_TIMER_ID
};
/* File system indexes in our FS combobox */

View file

@ -30,7 +30,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 206, 278
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "Rufus v1.0.2.83 (Beta)"
CAPTION "Rufus v1.0.2.84 (Beta)"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "Start",IDC_START,94,236,50,14
@ -65,7 +65,7 @@ BEGIN
DEFPUSHBUTTON "OK",IDOK,231,175,50,14,WS_GROUP
CONTROL "<a href=""https://github.com/pbatard/rufus/wiki/Rufus"">https://github.com/pbatard/rufus</a>",IDC_ABOUT_RUFUS_URL,
"SysLink",WS_TABSTOP,46,47,114,9
LTEXT "Version 1.0.2 (Build 83)",IDC_STATIC,46,19,78,8
LTEXT "Version 1.0.2 (Build 84)",IDC_STATIC,46,19,78,8
PUSHBUTTON "License...",IDC_ABOUT_LICENSE,46,175,50,14,WS_GROUP
EDITTEXT IDC_ABOUT_COPYRIGHTS,46,107,235,63,ES_MULTILINE | ES_READONLY | WS_VSCROLL
LTEXT "Report bugs or request enhancements at:",IDC_STATIC,46,66,187,8
@ -164,8 +164,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,2,83
PRODUCTVERSION 1,0,2,83
FILEVERSION 1,0,2,84
PRODUCTVERSION 1,0,2,84
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -182,13 +182,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "akeo.ie"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "1.0.2.83"
VALUE "FileVersion", "1.0.2.84"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "1.0.2.83"
VALUE "ProductVersion", "1.0.2.84"
END
END
BLOCK "VarFileInfo"

View file

@ -338,6 +338,25 @@ void CreateBoldFont(HDC dc) {
hBoldFont = CreateFontIndirect(&lf);
}
/*
* Create the application status bar
*/
void CreateStatusBar(void)
{
RECT rect;
int edge[2];
// Create the status bar.
hStatus = CreateWindowEx(0, STATUSCLASSNAME, NULL, WS_CHILD | WS_VISIBLE,
0, 0, 0, 0, hMainDialog, (HMENU)IDC_STATUS, hMainInstance, NULL);
// Create 2 status areas
GetClientRect(hMainDialog, &rect);
edge[0] = rect.right - (int)(58.0f*fScale);
edge[1] = rect.right;
SendMessage(hStatus, SB_SETPARTS, (WPARAM) 2, (LPARAM)&edge);
}
/*
* Center a dialog with regards to the main application Window or the desktop
*/