Archived

This topic is now archived and is closed to further replies.

Windows: From full-screen to windowed leaves ugliness?

This topic is 5499 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey there. I''m working on this windows encapsulation thing, and I''m trying to implement a full-screen/windowed mode toggle function, and it works to an extent. The thing is that it toggles to full-screen mode fine. The window changes to WS_POPUP style and fills the screen. Going back to windowed mode (or starting in full-screen and toggling to windowed) works as well, yet it doesn''t redraw the area around my window. This results in the entire screen, apart from my window, being filled with whiteness (the full-screen window was all-white), and when I drag the window around, the desktop (or whatever window was behind it) becomes visible where my window used to be. So you end up having to ''polish'' your desktop with my window to get rid of all the whiteness. I''m sure there''s something you can do to make windows redraw the entire screen, but I don''t know what. I''ve checked MSDN and Google on the SetWindowLongPtr and SetWindowPos functions, but I don''t see anything on screen redraws. Here''s my code:
  
void CApp::ToggleWindowed()
{
  m_Windowed = !m_Windowed;

  if (m_Windowed) // need to change to windowed mode

  {
    SetWindowLongPtr(m_hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW);
    SetWindowPos(m_hWnd, HWND_NOTOPMOST, 100, 100, 200, 200, SWP_SHOWWINDOW);
  }
  else  // need to change to full screen

  {
    SetWindowLongPtr(m_hWnd, GWL_STYLE, WS_OVERLAPPEDWINDOW);
    SetWindowPos(m_hWnd, HWND_NOTOPMOST, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), SWP_SHOWWINDOW);
  }
}
  
As said, this gives me a 100x100 window at 100,100 when toggling to windowed mode, but the rest of the screen doesn''t redraw and still shows what''s left of the full screen window. Anyone who can set me on the right path?

Share this post


Link to post
Share on other sites
Which API are you using? DX or OpenGL? Or Neither!?

To tell you the truth, your code looks quite strange...

Do not meddle in the affairs of moderators, for they are subtle and quick to anger.


ANDREW RUSSELL STUDIOS
Cool Links :: [ GD | TG | MS | NeHe | PA | SA | M&S | TA | LiT | H*R ]
Got Clue? :: [ Start Here! | Google | MSDN | GameDev.net Reference | OGL v D3D | File Formats | Go FAQ yourself ]

Share this post


Link to post
Share on other sites
Eh? I'm not using a graphics API, this is all just basic Windows stuff. I would've posted in the appropriate forum if I was using either D3D or OpenGL.

And what's strange about my code? The m_Windowed member specifies if the current window is Windowed or Fullscreen. When the toggle function is called, m_Windowed is negated, and based on its new value, the window's style attribute is changed (POPUP or OVERLAPPED) and the window is resized and placed in a new position. Nothing strange or exotic I can see.

So why does it look strange? It would be a bit more helpful if you said why it looks strange, in stead of just saying that it does.

[edited by - Bas Paap on November 22, 2002 1:13:02 PM]

Share this post


Link to post
Share on other sites
OK, not strange, but different. I see why now.

Perhaps distroying the window and recreating it might work better. I am not a winapi guru, I thought it was some sort of 3D API bug (that code is not going to win you any friends if you are using OGL/D3D)

Anyway. Carry on.

Do not meddle in the affairs of moderators, for they are subtle and quick to anger.


ANDREW RUSSELL STUDIOS
Cool Links :: [ GD | TG | MS | NeHe | PA | SA | M&S | TA | LiT | H*R ]
Got Clue? :: [ Start Here! | Google | MSDN | GameDev.net Reference | OGL v D3D | File Formats | Go FAQ yourself ]

Share this post


Link to post
Share on other sites