# Strange border behaviour fullscreen -> windowed

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

## Recommended Posts

Hi

My game can go windowed to fullscreen and back without any trouble. Borders are fine.

However, if I start the application in fullscreen, and then go to windowed mode, all borders are gone! If to try to refresh with going windowed to windowed with the same resolution nothing happens, but if I refresh going from windowed to windowed with another resolution the border pops back!

Can you tell what is wrong?

 void DEVICEOBJECT::ChangeResolution(GAMEWINDOW &gw) { gw.Height = max(gw.Height, 480); gw.Width = max(gw.Width, 640); ZeroMemory(&d3dpp, sizeof(d3dpp)); d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferFormat = gw.Format; d3dpp.MultiSampleType = D3DMULTISAMPLE_8_SAMPLES; d3dpp.Windowed = gw.Windowed; d3dpp.EnableAutoDepthStencil = TRUE; d3dpp.AutoDepthStencilFormat = D3DFMT_D16; if(!gw.Windowed) { d3dpp.BackBufferWidth = gw.Width; d3dpp.BackBufferHeight = gw.Height; } RECT rc; SetRect(&rc, 0, 0, gw.Width, gw.Height); DWORD grfStyle = gw.Windowed ? WS_OVERLAPPEDWINDOW&~WS_THICKFRAME&~WS_MAXIMIZEBOX : WS_EX_TOPMOST|WS_POPUP; AdjustWindowRectEx(&rc, grfStyle, FALSE, NULL); //UpdateWindow(hWnd); MoveWindow(hWnd,50, 50, rc.right-rc.left, rc.bottom-rc.top, true); SetWindowLong(hWnd, GWL_STYLE, grfStyle); ShowWindow(hWnd, SW_SHOW); ResetDevice(); return; } 

##### Share on other sites
Hi!

I think, the intended way for changing the resolution and the window mode is to directly modify the swap chain, instead of letting the window force the changes.
Here is some information on best practices (also ensuring that you get maximum performance in fullscreen mode). In case you haven't seen it yet, here is a DXGI Overview article.
Hope this helps to unravel this weird behavior.

Cheers!

##### Share on other sites
Hi, I still have the problem. I can't figure out what is wrong...

What else must be done besides change window style, window size, editing present parameters and calling d3ddev->Reset(&d3dpp)?

PS: This is a DX9 app Edited by Tispe

##### Share on other sites
Perhaps it's a simple case of the window not redrawing. Try adding SetWindowPos with SWP_FRAMECHANGED and SWP_DRAWFRAME flags.

##### Share on other sites

Hi!

I think, the intended way for changing the resolution and the window mode is to directly modify the swap chain, instead of letting the window force the changes.
Here is some information on best practices (also ensuring that you get maximum performance in fullscreen mode). In case you haven't seen it yet, here is a DXGI Overview article.
Hope this helps to unravel this weird behavior.

Cheers!

That relates to DXGI which is not going to be relevant for the OP, who is clearly using D3D9 (present parameters, etc).

Check the documentation for SetWindowLong: http://msdn.microsoft.com/en-us/library/windows/desktop/ms633591%28v=vs.85%29.aspx

Certain window data is cached, so changes you make using SetWindowLong will not take effect until you call the SetWindowPos function. Specifically, if you change any of the frame styles, you must call SetWindowPos with the SWP_FRAMECHANGED flag for the cache to be updated properly.[/quote]