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.
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://learn.microsoft.com/en-us/windows/uwp/packaging/app-capability-declarations
Please let us know your feedback.
Thanks,
Stefan Wick - Windows Developer Platform
Related
I have an application developed in Qt that causes Windows 10 to think it is a game, and opens a pop up box that says Press the Win-key + G to open the Game bar. This is very unhelpful as my application is not a game; and it interferes with the user experience. How can I turn this off from within my application code? I have been unable to find any documentation related to this. Thanks in advance.
It is not possible to neither capture Windows shortcuts (in order to stop propagation and disable them), nor to disable game bar in a per-app base.
Options you have are:
to disable it globally (see this post): you can do it using the Registry, so it can be included in an installation package, but you'll affect the global settings of the user,
change the shortcut used to access it in the Xbox app,
use some third-party app, such as AutoHotKey, to map keyboard sequences to an empty action (related question).
Edit:
Also you can (from user side) disable it for your app in Xbox app. (Xbox support):
Open Xbox app
In my games list select your app
Right click on it and delete it
This will delete your app from games list, so GameBar will not appear.
On devices with touch input Windows 10 displays nice touch-friendly menues, so i'm looking for a way to add this into my application. Is there any new flag or a method to show such a menu without making it completely owner-draw?
The control you are referencing is a MenuFlyout. Depending on whether you're using a mouse or touch, Windows 10 will automatically space the menu items closer/further to be optimal for the input you're using.
To use this control (the easy way), your app should be a Windows 10 Universal (UWP) app, which can be written in C#, VB and C++.
You can find official samples for UWP apps on GitHub.
I have created a windows application in C++ and I want to make so whenever I run it, it doesn't steal focus from whichever window is currently focused(or maybe steal the focus and give it back right away). I'm not creating any window so i'm not sure how to change the window style, my program runs in the background.
I couldn't find any answer that worked for C++, is there any way I can do this?
When you start your application by clicking on the EXE or shortcut, Windows Explorer takes focus, not your app. The only way to start your app and not let Windows Explorer take focus is to start your program when Windows starts, via registry key.
Make sure you use the extended style WS_EX_NOACTIVATE when using CreateWindowEx().
See the Microsoft Docs for CreateWindowEx.
I am trying to disable Norton auto protect. I don't actually want to close the program. If you click on the Norton icon it gives you the option to disable it.
I would like to write a program that clicks the button for me. I am just not sure how to go about this. I am using C++ and I have Visual Studio and Windows XP.
Do you want to close an application or disable an application (like disable java update etc)? If you are talking about closing an application using your program, you can use "TerminateProcess()".
If you are talking about disabling application, share with us particular use-case exactly what do you want to achieve?
I'm developing an application in C++ that's partially driven by touch-screen on Windows XP Embedded. Some text entry will be necessary for the user. So far we've been using the standard Windows On-Screen Keyboard (osk.exe), but there are two main problems:
It's rather small on a higher resolution screen which will probably make it hard for users to hit the right keys
It's too "ugly" for the customer, who'd like a slicker on-screen keyboard that integrates better with the custom look-and-feel of the application so far.
Therefore I'm looking for alternatives for the Windows On-Screen Keyboard (osk.exe) that allow a larger size of buttons and can be skinned. Ideally it would have a BSD-like license for unburdened integration into a commercial app, but a royalty-free commercial solution could work.
Do you know of any such applications, or have you had a similar project where you solved the issue in another way?
We are using Click-N-Type for our systems. It is completely resizable. It has some customization possibilities, but I never tried them. We use it on "normal" Windows XP, but it should work on Windows XP embedded also.
I know this question is tagged 'c++', but here's an option for .Net that I found and integrated with less than 5 minutes work. (I've looked, and there isn't a .Net flavour of this question, and I guess it could be ported to C++ with very little effort too).
It uses the standard Windows On-Screen Keyboard (osk.exe), resizes it, docks it to the bottom of the screen and removes the title and menu bars, all from one call in your application.
The Code Project - Manage Windows XP On Screen Keyboard
The download is a single VB.Net class.
please check WPF Component(http://fpscomponents.com/Product.aspx?id=8) that is fully customizable by inbuilt editor. So programmer can fill it with own language and define layout!
Check johngnazzo code:
http://www.daniweb.com/forums/thread4548.html#
Why not write your own keyboard UI? This would (should) be relatively trivial and give you complete control over its look and feel.
I programmed a On Screen Keyboard in Java.
This is working very fine when you want to tip into Java components and Java frames.
When you want to tip in every open window you have to send the key event by implementing Robot sender. The problem i have is that the focus owner get the sended key and when you open the keyboard the keyboard has the focus.
You can not realy implement a global Java keyboard, as far as i know.
When you only want to use the Keyboard for Java, use Java.
Otherwise you should use another language.
You should use a native language where you can handle the OS focus owner or a language where you can completly disable the keyboard focus but also can bring the keyboard to the front of the screen
Take a look at chessware virtual keyboard.
http://hot-virtual-keyboard.com/