|
|
1.1.1.3 ! root 1: /* The source code contained in this file has been derived from the source code ! 2: of Encryption for the Masses 2.02a by Paul Le Roux. Modifications and ! 3: additions to that source code contained in this file are Copyright (c) 2004 ! 4: TrueCrypt Team and Copyright (c) 2004 TrueCrypt Foundation. Unmodified ! 5: parts are Copyright (c) 1998-99 Paul Le Roux. This is a TrueCrypt Foundation ! 6: release. Please see the file license.txt for full license details. */ 1.1 root 7: 8: #include "TCdefs.h" 9: #include "progress.h" 10: #include "../format/resource.h" 11: 12: extern HWND hCurPage; 13: extern HWND hProgressBar; 14: extern BOOL bThreadCancel; 15: extern int nPbar; 16: 1.1.1.3 ! root 17: ULONG prevTime, startTime; ! 18: __int64 totalSectors; 1.1 root 19: 20: void 1.1.1.3 ! root 21: InitProgressBar (__int64 totalSecs) 1.1 root 22: { 23: HWND hProgressBar = GetDlgItem (hCurPage, nPbar); 24: SendMessage (hProgressBar, PBM_SETRANGE32, 0, 10000); 25: SendMessage (hProgressBar, PBM_SETSTEP, 1, 0); 26: 27: prevTime = startTime = GetTickCount (); 28: totalSectors = totalSecs; 29: } 30: 31: BOOL 1.1.1.3 ! root 32: UpdateProgressBar (__int64 nSecNo) 1.1 root 33: { 34: char text[100]; 35: HWND hProgressBar = GetDlgItem (hCurPage, nPbar); 36: int time = GetTickCount (); 37: 38: int elapsed = (time - startTime) / 1000; 39: 1.1.1.3 ! root 40: if ((nSecNo+1) / 2 / 1024 < 1000000) ! 41: wsprintf(text,"%d MB ", (nSecNo+1) / 2 / 1024); ! 42: else ! 43: wsprintf(text,"%d GB ", (nSecNo+1) / 2 / 1024 / 1024); ! 44: 1.1 root 45: SetWindowText (GetDlgItem (hCurPage, IDC_BYTESWRITTEN), text); 46: 1.1.1.3 ! root 47: if ((nSecNo+1) / 2 / 1024 / (1+elapsed) < 1024) ! 48: wsprintf(text,"%d MB/s ", (nSecNo+1) / 2 / 1024 / (1+elapsed)); ! 49: else ! 50: wsprintf(text,"%d GB/s ", (nSecNo+1) / 2 / 1024 / 1024 / (1+elapsed)); ! 51: 1.1 root 52: SetWindowText (GetDlgItem (hCurPage, IDC_WRITESPEED), text); 53: 54: if (nSecNo < totalSectors) 55: { 1.1.1.3 ! root 56: int min = (int)((totalSectors - nSecNo) / ((nSecNo+1)/(elapsed+1)+1) / 60); ! 57: ! 58: if (min < 60 * 24) ! 59: wsprintf(text,"%d min ", min); ! 60: else ! 61: wsprintf(text,"%d days ", min / (60 * 24)); ! 62: 1.1 root 63: SetWindowText (GetDlgItem (hCurPage, IDC_TIMEREMAIN), text); 64: } 65: 66: prevTime = time; 67: 68: SendMessage (hProgressBar, PBM_SETPOS, (int) (10000.0 * nSecNo / totalSectors), 0); 69: 70: return bThreadCancel; 71: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.