2
votes

I'm coding a short game in C++ and Win32, and I want to be able to make it in fullscreen with a fixed size. I also want the user to be able to switch focus between the game window and other windows as much as he/she wants without any weird screen glitches.

So far I know of the ChangeDisplaySettings function and creating the window with the WS_POPUP style at initialization to make it fullscreen. To detect the user switching focus to other windows by way of alt+tab or otherwise, what messages should I be handling on the window's WndProc or should I be using another function? When loss of focus is detected should I only call ChangeDisplaySettings(NULL, 0); or are there other functions I should call as well? And what method should I use to handle focus back into the window?

Also can anyone give me some info on how to make it work smoothly for different screen sizes?

Thanks for any help.

2
Full-screen and 'at a fixed size' are kind of conflicting requirements. You want full screen at the current resolution (user-chosen) or change the resolution and open a full-screen window? - JBRWilkinson
I want the window to be of size 640x480 and opened in a fullscreen window without the top window bar. - kaykun

2 Answers

0
votes

If you want an exclusive full screen window, use DirectX.

But I don't recommend it. Changing the display mode causes glitches, rearranges the users icons and so on. Whether done by you, or Direct X.

Rather create a normal window at your native res, and let the user maximize it if wanted.

0
votes

You could also use the GDI+ library of Windows XP (and newer) to use hardware-accelerated stretching (draw in 640x480, let GDI+ resize it to the native resolution). Then you don't need exclusive mode of DirectDraw nor ChangeDisplaySettings.

Also drawing into a 640x480 big background buffer and bit blitting it on the drawing surface via StretchBlt can be a performant solution.