If you, too, are scouring the Interwebs for the answer, here it is:
First, you’re going to need to download the Windows SDK to get the proper c++ header files to reference. In this particular case, you’re going to want to reference “windows.h” like so:
And then access the ChangeDisplaySettings function from the Windows API like so:
DEVMODE *dm=new DEVMODE();
And last but not least, you need to set your form/widget into fullscreenMode like so:
And what you get is the intended, most importantly OPTIMIZED minimal screen for drawing your graphics to. The idea is you don’t want to draw to fill up the end-user’s high resolution screen unless you have to, especially when it’s a simple 2D game.
But do note, this isn’t a complex implementation. If your local display driver, say Nvidia or ATI graphics driver is broken, then it won’t auto-magically fix the aspect ratio or whatever. That’s the case with my Windows 7 development machine and I have to set it to 640×480 manually via Nvidia Control Panel. Otherwise, this Windows API code only changes the resolution.
Oh, and before I forget and you noobs scream faulty coding, don’t forget to code somekind of escape mechanism to return back to normal. For example, set up the
keyPressed event on the form/widget to capture the ESCAPE key so that you can exit/close the application, thus returning your resolution back to what it originally was. I don’t know if this is a given, but it seems to work like that on Windows Vista and Windows 7.
Otherwise, I make no promises of it being safe code. But if it works for you, have fun.