# Changing window styles?

## Recommended Posts

Metus    168
Despite the two years of Win32 / DirectX development experience, I have NEVER managed to change the window style and adjust the client area using SetWindowLong and SetWindowPos. Now I REALLY need to toggle from fullscreen to windowed mode using those (and the IDirect3DDevice::Reset ofcourse) functions. The entire morning was spent just to try to adjust the darn client area using AdjustWindowRect - but with no luck at all. this is the code that actually works and if someone can help me to adjust the client area I'd be in you debt.
D3DPRESENT_PARAMETERS kParams = Renderer::GetParams();
kParams.Windowed = !kParams.Windowed;

if( kParams.Windowed == TRUE )
{
SetWindowLong( Renderer::GetHandle(), GWL_style, WS_OVERLAPPEDWINDOW | WS_VISIBLE );
SetWindowPos( Renderer::GetHandle(), 0, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_DRAWFRAME | SWP_NOSIZE);
}
else
{
SetWindowLong( Renderer::GetHandle(), GWL_style, WS_POPUP | WS_VISIBLE );
SetWindowPos( Renderer::GetHandle(), 0, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE );
}

Renderer::Reset( kParams );



##### Share on other sites
iMalc    2466
So you just want to restore a window from maximized to normal mode?
Why not just do this?:
ShowWindow(hWnd, SW_RESTORE);
possibly followed by a call to MoveWindow. You don't have to get rid of the frame when maximising, iirc. Just leave the style alone.