覆盖 Windows 10 通用应用程序 UWP 上的关闭框

Override Close Box on Windows 10 Universal Apps UWP(覆盖 Windows 10 通用应用程序 UWP 上的关闭框)

本文介绍了覆盖 Windows 10 通用应用程序 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?

我正在使用 C++,这需要用于 Windows 10 通用应用程序 UWP.我已经知道如何为 Win32 做到这一点.

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

推荐答案

评论正确.常规的商店应用目前无法做到这一点.

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

但是,在 Creators Update(和相应的 SDK)中,我们包含了一个预览 API,您现在可以查看该功能:

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

Windows.UI.Core.Preview.SystemNavigationManagerPreview 类提供了一个应用可以标记为已处理的 CloseRequested 事件.为了使活动正常运行,应用程序需要声明受限的confirmAppClose"功能:https://docs.microsoft.com/en-us/windows/uwp/packaging/app-capability-declarations

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.

谢谢,Stefan Wick - Windows 开发者平台

Thanks, Stefan Wick - Windows Developer Platform

这篇关于覆盖 Windows 10 通用应用程序 UWP 上的关闭框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:覆盖 Windows 10 通用应用程序 UWP 上的关闭框

基础教程推荐