c# - 在 WPF 应用程序中使用手写笔或手指按下触摸屏上的按钮时出现异常

标签 c# wpf stylus-pen

我有一个带有初始窗口的 WPF 应用程序,该窗口在启动时显示为 Splashscreen。在启动期间有一个后台线程,我们可以通过单击启动画面中的按钮来取消该线程。 使用鼠标并单击按钮取消时,一切正常。但是,如果我使用触摸屏单击此按钮,则应用程序偶尔会崩溃,以下是堆栈跟踪。该应用程序是在 Windows 7 64 位上运行的 64 位目标。

Severity:
Fatal


Stack Trace:
Exception 0
Message: Object reference not set to an instance of an object.

StackTrace:

at MS.Internal.PointUtil.TryClientToRoot(Point point, PresentationSource presentationSource, Boolean throwOnError, Boolean& success)
at System.Windows.Input.StylusDevice.GetPosition(IInputElement relativeTo)
at System.Windows.Input.StylusDevice.ChangeStylusOver(IInputElement stylusOver)
at System.Windows.Input.StylusLogic.PreProcessInput(Object sender, PreProcessInputEventArgs e)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
at System.Windows.Interop.HwndMouseInputProvider.PossiblyDeactivate(IntPtr hwndCapture, Boolean stillActiveIfOverSelf)
at System.Windows.Interop.HwndMouseInputProvider.Dispose()
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)

FromSubsystem:
PresentationCore
Help Link:
Not specified

有没有人遇到过这个问题?

最佳答案

您使用的是 Elo 触摸屏吗?我在带有 Elo 触摸屏的 StylusLogic OnDispatcherShutdown 中遇到了类似的崩溃。我已经解决了它,为 wpf ( Disable the RealTimeStylus for WPF Applications ) 禁用了 RealTimeStylus。对我来说,事件被处理了两次(在显示驱动程序和 wpf stylus 中),但是在 wpf Stylus 处理程序上,窗口已经被销毁了。在调用关闭窗口之前有一点延迟对我有用。

关于c# - 在 WPF 应用程序中使用手写笔或手指按下触摸屏上的按钮时出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14635862/

相关文章:

c# - 为什么下面的代码不能编译?

wpf - ComboBox ItemsSource 已更改 => SelectedItem 已损坏

ios - 在 iPad 上禁用手写笔滚动

c# - "Is there any way to access a pixel by in an image by particular position like(x,y) in opencvforunity"

c# - 为什么 (object)0 == (object)0 不同于 ((object)0).Equals((object)0)?

wpf - Idataerrorinfo 中如何调用索引器?

ios - 如何区分用户是用手指还是苹果铅笔点击屏幕?

c# - 我可以使用 BouncycaSTLe for C# 使用密码创建可重现的 PGP key 对吗?

c# - 将多个形状组合在一起的最佳方法是什么?