Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Override Close Box on Windows 10 Universal Apps UWP

I'm trying to prevent the app from being closed by clicking the Close box on the App Window. For example, having a text editor with unsaved changes, upon pressing Close Box, I would first display, "Do you want to save changes before exiting?"

How can I detect app wanting to close and prevent that from happening?

I'm using C++, and this needs to be for Windows 10 Universal Apps UWP. I already know how to do this for Win32.

like image 278
Esenthel Avatar asked Nov 13 '15 03:11

Esenthel


People also ask

How do I turn off UWP app?

So disable individually or via the top-most toggle - to OFF. Again, that is: Settings -> Privacy -> Background Apps then toggle to OFF for specific apps or turn "Let Apps run in the background" to OFF.

How do I remove UWP app from Windows 10?

To do this, press the Start button and go to Settings -> Apps -> Apps and features. In the list of apps, select the app to be uninstalled. Click the Uninstall button. This will only uninstall the UWP app in the current user's profile.

How do I make the UWP app full screen?

So here's the big reveal: you can easily full screen almost any UWP apps in Windows 10 just by hitting `Shift + Win + Enter` after focusing a UWP app. The shortcut should work with most UWP apps in Windows 10, but it may not work if an app doesn't allow the window to be maximized in the first place.

Can UWP run on Windows 10?

UWP is one choice for creating apps that run on Windows 10 and Windows 11 devices, and can be combined with other platforms. UWP apps can make use of Win32 APIs and .


1 Answers

The comments are correct. There is currently no way for a regular Store app to do this.

However, with the Creators Update (and corresponding SDK) we have included a preview API that you can now check out for this functionality:

The Windows.UI.Core.Preview.SystemNavigationManagerPreview class provides a CloseRequested event that an app can mark as handled. For the event to work the app will need to declare the restricted 'confirmAppClose' capability per: https://docs.microsoft.com/en-us/windows/uwp/packaging/app-capability-declarations

Please let us know your feedback.

Thanks, Stefan Wick - Windows Developer Platform

like image 156
Stefan Wick MSFT Avatar answered Oct 03 '22 23:10

Stefan Wick MSFT