在Windows7中,当你触摸屏幕时,触摸点会出现一个简短的动画。
在我的WPF应用程序中,我想显示我自己的触摸点,而不是显示Windows提供的触摸点。
对如何在应用程序中禁用它们有什么想法吗?
发布于 2010-04-17 14:35:45
今天在看Windows Touch的Surface Toolkit时发现了这一点,似乎做得很好。
// override on the Window class
protected override void OnSourceInitialized(EventArgs e)
{
EnableTabletGestures(this, false);
}
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
public static extern short GlobalAddAtom(string atom);
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
public static extern IntPtr RemoveProp(IntPtr hWnd, string atom);
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
public static extern int SetProp(IntPtr hWnd, string atom, IntPtr handle);
public bool EnableTabletGestures(Window window, bool enable)
{
var hWnd = ((HwndSource)PresentationSource.FromVisual(window)).Handle;
long num = 0L;
string atom = "MicrosoftTabletPenServiceProperty";
num = GlobalAddAtom(atom);
if (num == 0L)
{
return false;
}
if (enable)
{
return (RemoveProp(hWnd, atom).ToInt64() == 1L);
}
int num2 = 0x1010019;
return (SetProp(hWnd, atom, new IntPtr(num2)) == 1);
}发布于 2010-09-29 07:02:39
您可以在每个控件的基础上禁用它们,但最好的选择是,特别是对于您的特定情况,如果要在根应用程序的窗口和任何衍生窗口(包括弹出窗口)上执行此操作。将以下附加属性添加到XAML文件中的"“元素中,结果如下所示:
<Window x:Class="MyWPFTouchFreeApp"
... [<omitted elements>]
Stylus.IsTapFeedbackEnabled="False" Stylus.IsTouchFeedbackEnabled="False"
Stylus.IsPressAndHoldEnabled="False" Stylus.IsFlicksEnabled="False"
... [<any other omitted attributes>]
>
<Grid ...
</Grid>
</Window>此外,如果您使用Microsoft Surface Toolkit for Windows Touch (目前处于测试阶段),使用SurfaceWindow将自动禁用这些功能(弹出窗口仍需手动处理)。
https://stackoverflow.com/questions/1732977
复制相似问题