Refresh all the screen (with Windows)
-
Hi ! I have an application (a game in C++ with DirectX) where the player can change the size (property) of the client area. Ex: He has a screen about 1440x900 pixels, he can setup his client area (the game) in a 800x600 window, 1280x1024, etc. My PROBLEM is when the player size DOWN the client area (like... from 1280x1024 to 800x600), we still have the old "Picture" around the new client area of 800x600. The software still runs without any problem but windows don't refresh the screen (the other software or the desktop background. Is there any way to say to Windows OS to refresh all the screen or fire an event to all software to refresh there view ? Than you.:^)
Danny Gilbert, enginneer Montréal, Canada
-
Hi ! I have an application (a game in C++ with DirectX) where the player can change the size (property) of the client area. Ex: He has a screen about 1440x900 pixels, he can setup his client area (the game) in a 800x600 window, 1280x1024, etc. My PROBLEM is when the player size DOWN the client area (like... from 1280x1024 to 800x600), we still have the old "Picture" around the new client area of 800x600. The software still runs without any problem but windows don't refresh the screen (the other software or the desktop background. Is there any way to say to Windows OS to refresh all the screen or fire an event to all software to refresh there view ? Than you.:^)
Danny Gilbert, enginneer Montréal, Canada
This has more to do with how you've written your game than telling Windows to repaint everything. Without knowing what you mean by "size DOWN to client area", or how you're accomplishing this or anything else about your code, there's really nothing we can tell you. There is no method of telling Windows to repaint everything. Windows already know stuff needs to be repainted, normally it's just a matter of giving Windows the time to do it.
Dave Kreskowiak Microsoft MVP - Visual Basic
-
This has more to do with how you've written your game than telling Windows to repaint everything. Without knowing what you mean by "size DOWN to client area", or how you're accomplishing this or anything else about your code, there's really nothing we can tell you. There is no method of telling Windows to repaint everything. Windows already know stuff needs to be repainted, normally it's just a matter of giving Windows the time to do it.
Dave Kreskowiak Microsoft MVP - Visual Basic
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
-
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
This stuff just sets the window position and size. How about this. Does you game engine hog the CPU? You can find out in Task Manager. If the CPU utilization is pegged at 99-100, then Windows isn't getting any time to have the other application redraw themselves. Your have to modify your engine to be a little more friendly with the rest of teh system.
Dave Kreskowiak Microsoft MVP - Visual Basic
-
This stuff just sets the window position and size. How about this. Does you game engine hog the CPU? You can find out in Task Manager. If the CPU utilization is pegged at 99-100, then Windows isn't getting any time to have the other application redraw themselves. Your have to modify your engine to be a little more friendly with the rest of teh system.
Dave Kreskowiak Microsoft MVP - Visual Basic
Yes ! You are right. It only sets the size and the position of the windows inside the current desktop. IT TAKES 99% of the CPU. I never checked that before with any software I wrote... and I don't know why ! I design most of my time embedded application, so this is always the only software in the system. Some time, I design software for windows like TOOLS and other little stuff. GAMES is my home project. Is there something with the Windows Message loop ? Can I give sometime "the hand" or the control to the OS for a little time slice (for other software) ? How to do that ? Reducing cpu use about 5%, Is-it enough for Windows to update the screen, etc. In embedded system, I always try to don't use more tha 50-70% of the CPU time but with Windows, I was sure that Windows CONTROLS/HANDLE it for us. I never get involved with this issue on Windows. You are right, my GAME use 99% of the CPU. What to do ? Thanks.;)
Danny Gilbert, enginneer Montréal, Canada