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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.