Fullscreen management with WinAPI

12,941

These guys seem to cover all the options.

Win32: full-screen and hiding taskbar


New Edit: Based on a new comment, try this.

Trap the WM_ACTIVATE event in you app for that window. In that event call the GetWindowPlacement Function and hopefully you'll be on your way. Note the link to "SetWindowPlacement" at the bottom.

Share:
12,941
Xavier V.
Author by

Xavier V.

Professional programmer since 10 years, in the Video game industry since 4 years. Mainly C++/Python programmer. Love to learn new things.

Updated on August 01, 2022

Comments

  • Xavier V.
    Xavier V. over 1 year

    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,