void CNewWizDialog::OnWizardNext() { CNewWizPage* pPage = GetActivePage(); ASSERT(pPage); LRESULT lResult = pPage->OnWizardNext(); if (lResult == -1) return; // don't change pages if (lResult == 0) { POSITION Pos = m_PageList.Find(pPage); ASSERT(Pos); m_PageList.GetNext(Pos); if (Pos == NULL) return; // the current page was the last page pPage = (CNewWizPage*)m_PageList.GetAt(Pos); } else { pPage = GetPageByResourceID(lResult); if (pPage == NULL) return; } if (!ActivatePage(pPage)) return; // enable Back button; it will be enabled later on EnableBack(TRUE); // if we are on the last page, then disable the next button and enable the finish button if (pPage == GetLastPage()) { // DISABLE EVERYTHING FOR INSTALL PAGE EnableBack(FALSE); EnableNext(FALSE); EnableCancel(FALSE); EnableFinish(FALSE); } // if we are not on the last page disable finish button if (pPage != GetLastPage()) { EnableFinish(FALSE); } }
//---------------------------------------------------------------------- // // GotoPage // // Switch to a specified wizard page // //---------------------------------------------------------------------- bool CWizardWindow::GotoPage( int nPage, bool forward ) { RECT rc; POINT ul, lr; bool isInterior = false; // Make sure page is in range if ( nPage < 0 || nPage >= m_PageCnt ) return false; // Get pointers to current page and new page CPropPage * oldPage = CurrentPage(); CPropPage * newPage = GetPage( nPage ); // Update shared buttons if ( newPage->m_Type == CPropPage::ENTRY ) { // Entry page EnableBack( false ); EnableNext( true ); EnableCancel( true ); } else if ( newPage->m_Type == CPropPage::FINISH ) { // Exit page EnableFinish( true ); EnableCancel( false ); EnableBack( true ); } else { // Interior page isInterior = true; EnableNext( true ); EnableCancel( true ); EnableBack( true ); } // Set forward/backward status on pages newPage->m_Forward = forward; if ( oldPage ) oldPage->m_Forward = forward; // If new window hasn't been created, create it now if ( newPage->GetHwnd() == NULL ) { // Get window position if ( isInterior ) GetWindowRect( GetDlgItem( m_hWnd, IDC_PAGEFRAME ), &rc ); else GetWindowRect( GetDlgItem( m_hWnd, IDC_EXTPAGEFRAME ), &rc ); ul.y = rc.top; ul.x = rc.left; lr.y = rc.bottom; lr.x = rc.right; MapWindowPoints( HWND_DESKTOP, m_hWnd, &ul, 1 ); MapWindowPoints( HWND_DESKTOP, m_hWnd, &lr, 1 ); // create window newPage->m_hWnd = CreateDialogParam( m_hInstance, newPage->m_Template, m_hWnd, CPropPage::DialogProc, (LPARAM)newPage ); // Move window to correct location MoveWindow( newPage->m_hWnd, ul.x, ul.y, lr.x - ul.x, lr.y - ul.y, TRUE ); } // Set window text SetDlgItemText( m_hWnd, IDC_TITLE, newPage->m_HeaderTitle ); SetDlgItemText( m_hWnd, IDC_EXTTITLE, newPage->m_HeaderTitle ); SetDlgItemText( m_hWnd, IDC_SUBTITLE, newPage->m_HeaderSubTitle ); // Show/Hide graphical elements ShowWindow( GetDlgItem( m_hWnd, IDC_UPPERLINE ), isInterior ? SW_SHOW : SW_HIDE ); ShowWindow( GetDlgItem( m_hWnd, IDC_SUBTITLE ), isInterior ? SW_SHOW : SW_HIDE ); ShowWindow( GetDlgItem( m_hWnd, IDC_BANNER ), isInterior ? SW_SHOW : SW_HIDE ); ShowWindow( GetDlgItem( m_hWnd, IDC_TITLE ), isInterior ? SW_SHOW : SW_HIDE ); ShowWindow( GetDlgItem( m_hWnd, IDC_WATERMARK ), isInterior ? SW_HIDE : SW_SHOW ); ShowWindow( GetDlgItem( m_hWnd, IDC_EXTTITLE ), isInterior ? SW_HIDE : SW_SHOW ); // Place white background appropriately if ( isInterior ) { // Header GetWindowRect( GetDlgItem( m_hWnd, IDC_UPPERLINE ), &rc ); lr.x = rc.right; lr.y = rc.bottom - 2; MapWindowPoints( HWND_DESKTOP, m_hWnd, &lr, 1 ); ul.x = 0; ul.y = 0; } else { // Right size GetWindowRect( GetDlgItem( m_hWnd, IDC_EXTPAGEFRAME ), &rc ); ul.x = rc.left; ul.y = rc.top; lr.x = rc.right; lr.y = rc.bottom + 4; MapWindowPoints( HWND_DESKTOP, m_hWnd, &ul, 1 ); MapWindowPoints( HWND_DESKTOP, m_hWnd, &lr, 1 ); ul.y = 0; } SetWindowPos( GetDlgItem(m_hWnd,IDC_WHITEBACKGROUND), HWND_TOP, ul.x, ul.y, lr.x, lr.y, 0 ); // Make new window current. This ensures that if the new window calls us recursively we act relative to it. if ( forward ) newPage->m_Previous = m_CurrentPage; m_CurrentPage = nPage; // Hide old window if ( oldPage != NULL && oldPage->GetHwnd() ) ShowWindow( oldPage->GetHwnd(), SW_HIDE ); // Dispay new window ShowWindow( newPage->GetHwnd(), SW_SHOWNORMAL ); // Set focus to NEXT button, or first control of property page if ( IsWindowEnabled( GetDlgItem( m_hWnd, IDOK ) ) ) SetFocus( GetDlgItem( m_hWnd, IDOK ) ); else SetFocus( GetNextDlgTabItem( m_hWnd, GetDlgItem( m_hWnd, IDCANCEL ), false ) ); return true; }