Override the Close Window window in Window 10 Universal UWP Applications

I am trying to prevent the application from closing by clicking the "Close" button in the application window. For example, having a text editor with unsaved changes, after clicking the "Close" button, I must first display "Do you want to save the changes before exiting?"

How can I detect an application that wants to close and prevent this?

I am using C ++ and this should be for Windows 10 Universal Apps UWP. I already know how to do this for Win32. Thanks

+6
source share
1 answer

Comments are correct. There is currently no way for a regular Store app.

However, with the Creators update (and the corresponding SDK), we have included a preview API, which you can now check for this function:

The Windows.UI.Core.Preview.SystemNavigationManagerPreview class provides the CloseRequested event, which the application can mark as processed. In order for the event to work, the application will have to declare the limited confirmAppClose function: https://docs.microsoft.com/en-us/windows/uwp/packaging/app-capability-declarations

Please tell us your feedback.

Thanks Stefan Wick - a platform for Windows developers

+6
source

All Articles