I'm making a Direct3D app, and I can easily go from Windowed to Fullscreen mode using IDirect3DDevice9::Reset with new presentation parameters. However, when I use the same trick to go from fullscreen to windowed mode, the window has now lost its borders.
If I try doing SetWindowLong to set the window style to WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU (and then SetWindowPos with SWP_FRAMECHANGED), the window now gets its border, but the direct3d device no longer works. Resetting the device again doesn't work, and instead of Reset(), doing Release() then SetWindowLong() then CreateDevice() again, of course fails, as my managed resources are dependent on my device.
How do I make IDirect3DDevice9::Reset to go back to windowed mode, while creating a bordered window?
First, you need to change the properties of the window:
Next you have to release any resources you created in default pool -
D3DPOOL_DEFAULT(it's better to useD3DPOOL_MANAGEDif possible). If you don't,IDirect3DDevice9::Resetwill fail.Then you can reset the device and finally recreate any resources if needed. Make sure you set up
D3DPRESENT_PARAMETERSforIDirect3DDevice9::Resetcorrectly.