Skip to main content
gamedev.net
🔒 Locked

Toggle full screen

Started by DangerDave Jul 14, 2004 at 4:47 PM 6 replies 2.6k views
Original Post
DangerDave
DangerDave
I know this must be a really obvious question, and I've searched the forums and the net for the answer, but I'm either searching for the wrong words or just having a bad day. Currently the only way I've been using to toggle between full screen and windowed mode is to completely destroy everything relating to Direct3D then recreate with params.Windowed = TRUE. There must be a simpler way! Help much appreciated.
Dave.
Raloth
Raloth
Call Reset on your device with the new presentation parameters for fullscreen mode. You will have to release any resources not created with the Managed pool first. There are a few other things but you can find them by looking at the documentation for Reset at the MSDN.
____________________________________________________________AAAAA: American Association Against Adobe AcrobatYou know you hate PDFs...
DangerDave
DangerDave
EXCELLENT, just what I needed. Now why in the hell couldnt I find something so simple on the web?!?!?!

Next question now is, how do I restore the original window size and title bar, etc. Right now its only showing the client area and its still in 800X600 (desktop's at 1024X768, switches to 800X600 in fullscreen mode).
Dave.
Raloth
Raloth
If you mean switching back to windowed mode, it should be as simple as calling Reset again with the proper settings. I'm a little confused about what you are asking.
____________________________________________________________AAAAA: American Association Against Adobe AcrobatYou know you hate PDFs...
Supernat02
Supernat02
Is your question how to resize the window back to the original size? I would assume you just save the original size when the program starts and then reset the window size when they switch back to windowed mode. How to do that would depend on the type of IDE you are developing under, i.e. Visual C++, Visual.net, Managed C, etc.

Chris
Chris ByersMicrosoft DirectX MVP - 2005
DangerDave
DangerDave
I'm using the same params structure, except with Windowed set to TRUE or FALSE in the Reset function. I start in windowed mode and then go into full screen fine, but then coming back into windowed mode has a couple of problems. The main thing is that there is no title bar or border on the window when it comes out of full screen mode, there is just a box containing the D3D display, no minimize/maximize/close buttons... no title bar whatsoever.

The other problem is that I want an 800X600 resolution (for example), but shrunk to the size of the window - so that relative to the client area of the window everything's still in 800X600 mode, even when the window is resized... i.e. text and images stretch depending on the size of the window. This happens when I start in windowed mode, but not when I switch to fullscreen then back - the window remains like an 800X600 viewport on my 1024X768 desktop.

I hope this is a bit more descriptive. Help much appreciated.
Dave.
Evil Steve
Evil Steve
D3D changes your window type when it changes to fullscreen, but it doesn't change it back.
Heres what i use:
if(m_thePresentParams.Windowed){   RECT rc;   const DWORD dwStyle = WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU;   rc.left = rc.top = 0;   rc.right = nWidth;   rc.bottom = nHeight;   AdjustWindowRect(&rc,dwStyle,FALSE);   rc.right -= rc.left;   rc.bottom -= rc.top;   SetWindowPos(m_hWnd,HWND_TOP,(GetSystemMetrics(SM_CXSCREEN)-rc.right)/2,      (GetSystemMetrics(SM_CYSCREEN)-rc.bottom)/2,0,0,SWP_NOSIZE | SWP_FRAMECHANGED);   ShowCursor(TRUE);}

If you call that code just after calling IDirect3DDevice9::Reset() it should work.
DangerDave
DangerDave
Cheers not-so-Evil Steve, that code was a bit more than I needed, but certainly SetWindowPos and GetSystemMetrics seems to have solved the problem. Thanks for that.
Dave.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.