Changeset 535


Ignore:
Timestamp:
11/13/2008 9:56:14 AM (3 years ago)
Author:
lowjoel
Message:

-Calculate the progress of the extraction
-Added functions to handle the progress updates on-screen

Location:
branches/eraser6/Installer/Bootstrapper
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/eraser6/Installer/Bootstrapper/Bootstrapper.cpp

    r534 r535  
    3535        InStream.Seek = LzFileStreamSeek; 
    3636        FileHandle = fileHandle; 
     37 
     38        FileRead = FileRead = 0; 
     39        LARGE_INTEGER largeInt; 
     40        largeInt.QuadPart = 0; 
     41        if (!SetFilePointerEx(FileHandle, largeInt, &largeInt, FILE_CURRENT)) 
     42            throw GetErrorMessage(GetLastError()); 
     43 
     44        long long currPos = largeInt.QuadPart; 
     45        largeInt.QuadPart = 0; 
     46        if (!SetFilePointerEx(FileHandle, largeInt, &largeInt, FILE_END)) 
     47            throw GetErrorMessage(GetLastError()); 
     48        FileSize = largeInt.QuadPart - currPos; 
     49 
     50        largeInt.QuadPart = currPos; 
     51        if (!SetFilePointerEx(FileHandle, largeInt, NULL, FILE_BEGIN)) 
     52            throw GetErrorMessage(GetLastError()); 
    3753    } 
    3854 
     
    4359 
    4460    ISzInStream InStream; 
     61 
     62private: 
    4563    HANDLE FileHandle; 
    46  
    47 private: 
     64    long long FileRead; 
     65    long long FileSize; 
     66 
    4867    static SZ_RESULT LZFileStreamRead(void* object, void** bufferPtr, size_t size, 
    4968        size_t* processedSize) 
     
    6180            *bufferPtr = buffer; 
    6281            *processedSize = readSize; 
     82            s->FileRead += readSize; 
     83 
     84            SetProgress((double)s->FileRead / s->FileSize); 
    6385        } 
    6486 
     
    128150    unsigned blockIndex = 0; 
    129151    Byte* outBuffer = NULL; 
    130     size_t outBufferSize = 0; 
     152    size_t outBufferSize = 524288; 
    131153    for (unsigned i = 0; i < db.Database.NumFiles; ++i) 
    132154    { 
  • branches/eraser6/Installer/Bootstrapper/Bootstrapper.h

    r534 r535  
    3737HWND GetTopWindow(); 
    3838 
     39void SetProgress(float progress); 
     40void SetProgressIndeterminate(); 
     41void SetMessage(std::wstring message); 
     42 
    3943/// Retrieves the path to the executable file. 
    4044std::wstring GetApplicationPath(); 
  • branches/eraser6/Installer/Bootstrapper/Main.cpp

    r533 r535  
    3838    HINSTANCE hInstance = NULL; 
    3939    HWND hWndParent = NULL; 
     40    HWND hWndStatusLbl = NULL; 
     41    HWND hWndProgressBar = NULL; 
     42    HWND hWndCancelBtn = NULL; 
    4043 
    4144    bool              InitInstance(HINSTANCE hInstance, HWND& hWnd); 
     
    6063        ~TempDir() 
    6164        { 
     65            //TODO: remove files in the directory. 
    6266            RemoveDirectoryW(DirName.c_str()); 
    6367        } 
     
    111115            if ( !::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0) ) 
    112116            { 
    113     #if WINVER >= 0x0600 
     117#if WINVER >= 0x0600 
    114118                // a new field has been added to NONCLIENTMETRICS under Vista, so 
    115119                // the call to SystemParametersInfo() fails if we use the struct 
     
    118122                ncm.cbSize -= sizeof(int); 
    119123                if ( !::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0) ) 
    120     #endif 
     124#endif 
    121125                    return; 
    122126            } 
     
    181185    HWND hWndPanel = CreateWindowExW(0, STATIC_CLASS, NULL, WS_CHILD | WS_VISIBLE, 
    182186        0, 0, 294, 104, hWndParent, NULL, hInstance, NULL); 
    183     HWND hWndStatusLbl = CreateWindowExW(0, STATIC_CLASS, L"Extracting setup files...", 
     187    hWndStatusLbl = CreateWindowExW(0, STATIC_CLASS, L"Extracting setup files...", 
    184188        WS_CHILD | WS_VISIBLE, 13, 38, 270, 19, hWndPanel, NULL, hInstance, NULL); 
    185     HWND hWndProgressBar = CreateWindowExW(0, PROGRESS_CLASS, NULL, 
    186         WS_CHILD | WS_VISIBLE, 13, 13, 270, 24, hWndPanel, NULL, hInstance, NULL); 
    187     HWND hWndCancelBtn = CreateWindowExW(0, BUTTON_CLASS, L"Cancel", WS_TABSTOP | 
     189    hWndProgressBar = CreateWindowExW(0, PROGRESS_CLASS, NULL, 
     190        WS_CHILD | WS_VISIBLE | PBS_SMOOTH, 13, 13, 270, 24, hWndPanel, NULL, 
     191        hInstance, NULL); 
     192    hWndCancelBtn = CreateWindowExW(0, BUTTON_CLASS, L"Cancel", WS_TABSTOP | 
    188193        WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON, 193, 65, 90, 23, hWndPanel, NULL, 
    189194        hInstance, NULL); 
     
    195200    SetWindowFont(hWndProgressBar); 
    196201    SetWindowFont(hWndCancelBtn); 
     202    SendMessage(hWndProgressBar, PBM_SETRANGE, 0, MAKELPARAM(0, 1000)); 
    197203 
    198204    ShowWindow(hWndParent, nCmdShow); 
     
    228234} 
    229235 
     236void SetProgress(float progress) 
     237{ 
     238    SetWindowLong(hWndProgressBar, GWL_STYLE, 
     239        GetWindowLong(hWndProgressBar, GWL_STYLE) & (~PBS_MARQUEE)); 
     240    SendMessage(hWndProgressBar, PBM_SETPOS, (int)(progress * 1000), 0); 
     241} 
     242 
     243void SetProgressIndeterminate() 
     244{ 
     245    SetWindowLong(hWndProgressBar, GWL_STYLE, 
     246        GetWindowLong(hWndProgressBar, GWL_STYLE) | PBS_MARQUEE); 
     247    SendMessage(hWndProgressBar, PBM_SETMARQUEE, true, 100); 
     248} 
     249 
     250void SetMessage(std::wstring message) 
     251{ 
     252} 
     253 
    230254void Yield() 
    231255{ 
Note: See TracChangeset for help on using the changeset viewer.