My code is like the following: 1- Change property of the client and the window 2- Destroy old scene, free memory 3- Resize 4- Create new scene 5- SetWindowPos ;) bool CGameEngine::ChangeWindowsSize( int NewWidth, int NewHeight ) { // Windows SetWindowLong( m_hWnd, GWL_style, m_dwWindowstyle ); // Resize window and put it on left-top corner. Player will then move // the window where he wants. m_WindowsWidth = NewWidth; m_WindowsHeigth = NewHeight; m_rcClient.left = 0; m_rcClient.top = 0; m_rcClient.right = m_rcClient.left + NewWidth; m_rcClient.bottom = m_rcClient.top + NewHeight; m_rcWindow.left = 0; m_rcWindow.top = 0; m_rcWindow.right = m_rcWindow.left + NewWidth; m_rcWindow.bottom = m_rcWindow.top + NewHeight; m_MiddleX = m_WindowsWidth / 2; m_MiddleY = m_WindowsHeigth / 2; // Destroy object in the old scene. switch ( m_ActualScene ) { case MAIN_MENU: m_pSceneMainMenu->DestroyFinal(); SAFE_DELETE( m_pSceneMainMenu ); break; // ... other scene } // Resize the screen like the user wants. if( FAILED( m_pGraph3DEngine->Resize( m_WindowsWidth, m_WindowsHeigth )) ) { return false; } else { switch ( m_ActualScene ) { case MAIN_MENU: m_pSceneMainMenu = new CSceneMainMenu( this ); m_pSceneMainMenu->SetRatioWindow( ( float)m_WindowsWidth/(float)m_WindowsHeigth ); m_pSceneMainMenu->Create(); break; // ... other scene... } if( FAILED( SetWindowPos( m_hWnd, HWND_NOTOPMOST, 0, 0, NewWidth, NewHeight, SWP_SHOWWINDOW ) ) ) { ErrorExit("SetWindowPos"); } return true; } return false; }
Danny Gilbert, enginneer Montréal, Canada