Changeset 541


Ignore:
Timestamp:
11/13/2008 11:32:25 AM (6 years ago)
Author:
lowjoel
Message:

Move SetWindowFont? to the MainWindow? class.

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

Legend:

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

    r539 r541  
    6565 
    6666private: 
    67  
    6867    /// Registers the main window class and creates it. 
    6968    bool InitInstance(); 
     69 
     70    /// Helper function to set the window font for created windows to the system default. 
     71    void SetWindowFont(HWND hWnd); 
    7072}; 
    7173 
  • branches/eraser6/Installer/Bootstrapper/Main.cpp

    r540 r541  
    3737    //Static variables 
    3838    HINSTANCE hInstance = NULL; 
    39  
    40     bool              InitInstance(HINSTANCE hInstance, HWND& hWnd); 
    41     void              SetWindowFont(HWND hWnd); 
    4239    LRESULT __stdcall WndProc(HWND, UINT, WPARAM, LPARAM); 
    4340 
     
    8279        std::wstring DirName; 
    8380    }; 
    84  
    85      
    86      
    87  
    88     /// Helper function to set the window font for created windows to the system default. 
    89     void SetWindowFont(HWND hWnd) 
    90     { 
    91         HFONT hWndFont = NULL; 
    92         if (!hWndFont) 
    93         { 
    94             NONCLIENTMETRICS ncm; 
    95             ::ZeroMemory(&ncm, sizeof(ncm)); 
    96             ncm.cbSize = sizeof(ncm); 
    97  
    98             if ( !::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0) ) 
    99             { 
    100 #if WINVER >= 0x0600 
    101                 // a new field has been added to NONCLIENTMETRICS under Vista, so 
    102                 // the call to SystemParametersInfo() fails if we use the struct 
    103                 // size incorporating this new value on an older system -- retry 
    104                 // without it 
    105                 ncm.cbSize -= sizeof(int); 
    106                 if ( !::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0) ) 
    107 #endif 
    108                     return; 
    109             } 
    110  
    111             hWndFont = CreateFontIndirectW(&ncm.lfMessageFont); 
    112         } 
    113  
    114         SendMessage(hWnd, WM_SETFONT, (WPARAM)hWndFont, MAKELPARAM(TRUE, 0)); 
    115     } 
    11681 
    11782    /// Processes messages for the main window. 
     
    286251} 
    287252 
     253void MainWindow::SetWindowFont(HWND hWnd) 
     254{ 
     255    HFONT hWndFont = NULL; 
     256    if (!hWndFont) 
     257    { 
     258        NONCLIENTMETRICS ncm; 
     259        ::ZeroMemory(&ncm, sizeof(ncm)); 
     260        ncm.cbSize = sizeof(ncm); 
     261 
     262        if ( !::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0) ) 
     263        { 
     264#if WINVER >= 0x0600 
     265            // a new field has been added to NONCLIENTMETRICS under Vista, so 
     266            // the call to SystemParametersInfo() fails if we use the struct 
     267            // size incorporating this new value on an older system -- retry 
     268            // without it 
     269            ncm.cbSize -= sizeof(int); 
     270            if ( !::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0) ) 
     271#endif 
     272                return; 
     273        } 
     274 
     275        hWndFont = CreateFontIndirectW(&ncm.lfMessageFont); 
     276    } 
     277 
     278    SendMessage(hWnd, WM_SETFONT, (WPARAM)hWndFont, MAKELPARAM(TRUE, 0)); 
     279} 
     280 
    288281void MainWindow::SetProgress(float progress) 
    289282{ 
Note: See TracChangeset for help on using the changeset viewer.