Original Post
Hello.
I am trying to implement the ability to change between fullscreen and windowed display modes. I can currently start the app in either mode correctly. If switching from windowed to fullscreen everything is fine. Then entire screen clears to blue and the window sets to WS_POPUP. But in going from fullscreen back to windowed, the whole window area gets cleared to blue instead of just the clients area. The Menu bar and such are there because they react to mouse clicks but they do not show.
When I start the app I go through the normal windows process of creating a window 640x480 on an 800x600 display.
In setting up DirectX I initialize two separate D3DPRESENT_PARAMS. One for windowed and one for fullscreen. These remain during runtime to make it easier to switch between them.
I then call CreateDevice with the appropriate set of PRESENT_PARAMS. This part works groovy. I have these functions for changing modes.
void cGraphicsManager::ToggleFullscreen()
{
if(m_bWindowed)
{
m_bWindowed = false;
AdjustWindowForChange();
Reset3DEnvironment();
}
else
{
m_bWindowed = true;
AdjustWindowForChange();
Reset3DEnvironment();
}
}
void cGraphicsManager::AdjustWindowForChange()
{
if( m_bWindowed )
{
// Set windowed-mode style
SetWindowLong( cGlobalApp.GethWnd(), GWL_EXSTYLE,
m_dwWindowStyle );
}
else
{
// Set fullscreen-mode style
SetWindowLong( cGlobalApp.GethWnd(), GWL_EXSTYLE,
m_dwFullscreenStyle );
}
}
void cGraphicsManager::Reset3DEnvironment()
{
HRESULT hr;
// Reset the device
if(m_bWindowed)
{
hr = m_pd3ddCurrentDevice->Reset(&m_ppWindowed);
if(hr != D3D_OK)
{
MessageBox(cGlobalApp.GethWnd(),
"Reset", "Reset3DEnvironment",
MB_YESNO);
}
SetWindowPos(cGlobalApp.GethWnd(), HWND_TOP, m_iXPos,
m_iYPos, m_iWindowWidth, m_iWindowHeight,
SWP_SHOWWINDOW);
}
else
{
hr = m_pd3ddCurrentDevice->Reset(&m_ppFullscreen);
if(hr != D3D_OK)
{
MessageBox(cGlobalApp.GethWnd(), "Reset",
"Reset3DEnvironment", MB_YESNO);
}
}
}
Any ideas here?
Thanks,
Webby