Annotation of truecrypt/common/progress.c, revision 1.1.1.1

1.1       root        1: /* Copyright (C) 2004 TrueCrypt Team, truecrypt.org
                      2:    This product uses components written by Paul Le Roux <[email protected]> */
                      3: 
                      4: #include "TCdefs.h"
                      5: #include "progress.h"
                      6: #include "../format/resource.h"
                      7: 
                      8: extern HWND hCurPage;
                      9: extern HWND hProgressBar;
                     10: extern BOOL bThreadCancel;
                     11: extern int nPbar;
                     12: 
                     13: ULONG prevTime, startTime, totalSectors;
                     14: 
                     15: void
                     16: InitProgressBar (ULONG totalSecs)
                     17: {
                     18:        HWND hProgressBar = GetDlgItem (hCurPage, nPbar);
                     19:        SendMessage (hProgressBar, PBM_SETRANGE32, 0, 10000);
                     20:        SendMessage (hProgressBar, PBM_SETSTEP, 1, 0);
                     21: 
                     22:        prevTime = startTime = GetTickCount ();
                     23:        totalSectors = totalSecs;
                     24: }
                     25: 
                     26: BOOL
                     27: UpdateProgressBar (int nSecNo)
                     28: {
                     29:        char text[100];
                     30:        HWND hProgressBar = GetDlgItem (hCurPage, nPbar);
                     31:        int time = GetTickCount ();
                     32: 
                     33:        int elapsed = (time - startTime) / 1000;
                     34: 
                     35:        wsprintf(text,"%d MB ", (nSecNo+1) / 2 / 1024);
                     36:        SetWindowText (GetDlgItem (hCurPage, IDC_BYTESWRITTEN), text);
                     37: 
                     38:        wsprintf(text,"%d MB/s ", (nSecNo+1) / 2 / 1024 / (1+elapsed));
                     39:        SetWindowText (GetDlgItem (hCurPage, IDC_WRITESPEED), text);
                     40: 
                     41:        if (nSecNo < totalSectors)
                     42:        {
                     43:                wsprintf(text,"%d min ", (totalSectors  - nSecNo) / ((nSecNo+1)/(elapsed+1)+1) / 60);
                     44:                SetWindowText (GetDlgItem (hCurPage, IDC_TIMEREMAIN), text);
                     45:        }
                     46: 
                     47:        prevTime = time;
                     48: 
                     49:        SendMessage (hProgressBar, PBM_SETPOS, (int) (10000.0 * nSecNo / totalSectors), 0);
                     50: 
                     51:        return bThreadCancel;
                     52: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.