覆盖 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

请告诉我们您的反馈.

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

Thanks, Stefan Wick - Windows Developer Platform

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

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

基础教程推荐