Skip to content

Instantly share code, notes, and snippets.

@gyakoo
Last active April 2, 2018 00:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gyakoo/cfef3ca0403d26a082afc8c055240082 to your computer and use it in GitHub Desktop.
Save gyakoo/cfef3ca0403d26a082afc8c055240082 to your computer and use it in GitHub Desktop.
UWP C++ Fullscreen snippet
// Made this code to change to fullscreen, useful if you're creating a DX application in vs2015/c++/uwp
// Also look at this sample: https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/FullScreenMode/cpp
// And this MSDN page: https://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.viewmanagement.applicationview.preferredlaunchwindowingmode?cs-save-lang=1&cs-lang=cpp#code-snippet-1
// preferred mode in constructor
App::App()
{
// starts with this window size
Windows::UI::ViewManagement::ApplicationView::PreferredLaunchViewSize= Windows::Foundation::Size(800,600);
Windows::UI::ViewManagement::ApplicationView::PreferredLaunchWindowingMode = Windows::UI::ViewManagement::ApplicationViewWindowingMode::PreferredLaunchViewSize;
}
// call to this to set to FS
void App::ToggleToFullscreen()
{
auto av = Windows::UI::ViewManagement::ApplicationView::GetForCurrentView();
if (!av->IsFullScreenMode)
{
if (av->TryEnterFullScreenMode())
{
av->FullScreenSystemOverlayMode = Windows::UI::ViewManagement::FullScreenSystemOverlayMode::Minimal;
}
}
else
{
av->ExitFullScreenMode();
av->FullScreenSystemOverlayMode = Windows::UI::ViewManagement::FullScreenSystemOverlayMode::Standard;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment