Override Close Box on Windows 10 Universal Apps 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 上的关闭框


基础教程推荐
- 初始化列表*参数*评估顺序 2021-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- CString 到 char* 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01