How to well use the WinAPI to manage the fullscreen mode on windows's window ?
Here is my problem :
I have an application which has to be fullscreen.
I use ChangeDisplaySettings() function (winuser.h) with the CDS_FULLSCREEN value to put my window to fullscreen mode when receiving a WM_ACTIVATE
with (wParam == WA_ACTIVE || wParam == WA_CLICKACTIVE)
:
DEVMODE dmScreenSettings;
memset (&dmScreenSettings, 0, sizeof (dmScreenSettings));
dmScreenSettings.dmSize = sizeof (dmScreenSettings);
dmScreenSettings.dmPelsWidth = 1280;
dmScreenSettings.dmPelsHeight = 720;
dmScreenSettings.dmBitsPerPel = 32;
dmScreenSettings.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN);
I use the same function with the CDS_RESET value to put it back in "normal" mode when receiving a WM_ACTIVATE
with (wParam == WA_INACTIVE)
:
ChangeDisplaySettings(&dmScreenSettings, CDS_RESET);
When I first launch my application, it is in fullscreen. I use ALT+TAB to switch to another application on my computer. My application minimized itself. It works well. Then, I switch back to my application, and it comes up in fullscreen mode. Again, it works well. But if I want to switch back to another application one more time, my application statys in fullscreen mode, hiding all others applications on my computer.
NB : My window is created using CreateWindowEx() function with the following parameters :
DWORD dwExStyle = WS_EX_TOPMOST;
DWORD dwStyle = WS_VISIBLE | WS_POPUP;
1) Is there another way than using ChangeDisplaySettings() to change the fullscreen mode ?
2) Am I using it the good values ?
3) Is there anything to do that I forgot ?
Thanks in advance for all your answers. Best regards,