示例#1
0
LRESULT CRetrySplashScreen::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
    
    // SetForegroundWindow() was deprecated for Vista (attn: session 0 isolation)
    // Use SetWindowPos() for Vista+ in order to bring the window to the top of the Z order
    if (IsPlatformWindowsVista()){
        SetWindowPos(HWND_TOPMOST,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE);
        SetWindowPos(HWND_NOTOPMOST,0,0,0,0,SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE);
    } else {
        if (::SetForegroundWindow(GetDlgItem(IDOK)) == NULL){
            return 1;
        }
    }
    
    return 0;
    
}
示例#2
0
//=--------------------------------------------------------------------------=
// CWelcomeDialog::OnInitDialog
//=--------------------------------------------------------------------------=
// Message handler for WM_INITDIALOG
//
// Parameters:
//	uMsg	    Windows Message
//	wParam	    WPARAM
//	lParam	    LPARAM
//	bHandled    FALSE if not handled
//
// Output:
//	LRESULT	    
//
// Notes:
//
LRESULT CWelcomeDialog::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{

    m_hDlgBrush1 = CreateSolidBrush(RGB(231, 229, 213)); //default windows bg color
    m_hMemDC = NULL;
    m_hDialogFont = NULL;
    m_hDialogHeaderFont = NULL;

    HWND hWnd;
    DWORD style;

    // Allow SS_NOTIFY msgs for the URL links
    hWnd = GetDlgItem(IDC_WELCOME_CLICK_HERE);
    style = ::GetWindowLong(hWnd, GWL_STYLE);
    ::SetWindowLong(hWnd, GWL_STYLE, style | SS_NOTIFY);    
    hWnd = GetDlgItem(IDC_WELCOME_LICENSE_AGREEMENT);
    style = ::GetWindowLong(hWnd, GWL_STYLE);
    ::SetWindowLong(hWnd, GWL_STYLE, style | SS_NOTIFY);

    if (getIsAltInstallDir()) {
        CheckDlgButton(IDC_WELCOME_CHECKBOX, BST_CHECKED);
    }

    // Make dialog box not having any focus by default
    // Set Keyboard focus on a 0 size button
    GotoDlgCtrl(GetDlgItem(IDNO));
    
    // SetForegroundWindow() was deprecated for Vista (attn: session 0 isolation)
    // Use SetWindowPos() for Vista+ in order to bring the window to the top of the Z order
    // First call without SHOWWINDOW for TOPMOST window handles, then 2nd call with SHOWWINDOW for NOTOPMOST
    // has the same effect as BringWindowToTop()...both are suggested implementations for Vista's answer
    // to "stealing focus" problem. Note: SwitchToThisWindow() was removed, as it will not work on some varients of Window Vista.
    if (IsPlatformWindowsVista()){
        SetWindowPos(HWND_TOPMOST,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE);
        SetWindowPos(HWND_NOTOPMOST,0,0,0,0,SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE);
    } else {
        if (::SetForegroundWindow(GetDlgItem(IDOK)) == NULL){
            return 1; // If error, Let the system set the focus
        }
    }

    return 0;

}