Initial WPF content migrated (#17)

* Reset branch for WPF changes

* Convert BMP to PNG; fix link-out-of-scope err

* Add snippets for WPF... 6794 files!!!!

* Add missing snippets

* update file updated between migration

* Fix paths to include

* update breadcrumb and toc

* fix index links

* fix index links

* fix index links

* fix markdown
This commit is contained in:
Andy De George
2020-09-04 09:46:28 -07:00
committed by GitHub
parent dba50d6bf1
commit da363692ff
8215 changed files with 508408 additions and 11 deletions
@@ -0,0 +1,52 @@
---
title: Disable the RealTimeStylus
ms.date: "03/30/2017"
ms.assetid: e0525309-5ede-4782-837d-dbf6e5554859
---
# Disable the RealTimeStylus for WPF Applications
Windows Presentation Foundation (WPF) has built in support for processing Windows 7 touch input. The support comes through the tablet platforms real-time stylus input as <xref:System.Windows.UIElement.OnStylusDown%2A>, <xref:System.Windows.UIElement.OnStylusUp%2A>, and <xref:System.Windows.UIElement.OnStylusMove%2A> events. Windows 7 also provides multi-touch input as Win32 WM_TOUCH window messages. These two APIs are mutually exclusive on the same HWND. Enabling touch input via the tablet platform (the default for WPF applications) disables WM_TOUCH messages. As a result, to use WM_TOUCH to receive touch messages from a WPF window, you must disable the built-in stylus support in WPF. This is applicable in a scenario such as a WPF window hosting a component that uses WM_TOUCH.
To disable WPF listening to stylus input, remove any tablet support added by the WPF window.
## Example
The following sample code shows how to remove the default tablet platform support by using reflection.
```csharp
public static void DisableWPFTabletSupport()
{
// Get a collection of the tablet devices for this window.
TabletDeviceCollection devices = System.Windows.Input.Tablet.TabletDevices;
if (devices.Count > 0)
{
// Get the Type of InputManager.
Type inputManagerType = typeof(System.Windows.Input.InputManager);
// Call the StylusLogic method on the InputManager.Current instance.
object stylusLogic = inputManagerType.InvokeMember("StylusLogic",
BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.NonPublic,
null, InputManager.Current, null);
if (stylusLogic != null)
{
// Get the type of the stylusLogic returned from the call to StylusLogic.
Type stylusLogicType = stylusLogic.GetType();
// Loop until there are no more devices to remove.
while (devices.Count > 0)
{
// Remove the first tablet device in the devices collection.
stylusLogicType.InvokeMember("OnTabletRemoved",
BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.NonPublic,
null, stylusLogic, new object[] { (uint)0 });
}
}
}
}
```
## See also
- [Intercepting Input from the Stylus](intercepting-input-from-the-stylus.md)