windowsuwpvisual-studio-2019c++-cx

Automatic Full-Screen Mode for Windows UWP C++/CX Application


I'm working on a Windows UWP (Universal Windows Platform) C++/CX Application. I would like for this application to be full-screen from the moment that it launches, rather than briefly not full-screen and then changed to full-screen later. Does anyone know of a way to achieve this?


Solution

  • I found a solution for this issue. I start my App::OnLaunched() function as follows:

    void App::OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ e)
    {
        ApplicationView^ view = ApplicationView::GetForCurrentView();
    
        Windows::Foundation::Rect r;
        Windows::Foundation::Size sz;
        //view->SetPreferredMinSize(r)
        bool b = view->TryEnterFullScreenMode();
        int c = 0;
        while (b == false) {
            b = view->TryEnterFullScreenMode();
            c++;
            if (c == 100) {
                exit(1);
            }
        }
        r = view->VisibleBounds;
        sz = Windows::Foundation::Size(r.Width, r.Height);
        view->SetPreferredMinSize(sz);
        .....
    
    

    The code continually tries to set the window as full-screen, and exits if it cannot achieve this. Then once the window is full-screen, the code sets the preferred minimum window size to the dimensions of the full-screen.

    But that's not sufficient, because the application (or more precisely, the splash screen) starts in not-full-screen mode and then shifts to full-screen mode later.

    So the last thing is to adjust the application's splash-screen in Package.appxmanifest. I created a large 2480x1200 monochrome image using the photo editor GIMP, and then used this as my splash-screen image in Package.appxmanifest. I then ensure that only the "Scale400" (the 2480x1200 scaled version) of this PNG is the only "SplashScreen..." image present in my Assets\ directory.

    And with all of these changes, the application (splash-screen included) is full-screen from the moment it is launched.