首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在WPF中禁用Windows 7触摸动画

在WPF中禁用Windows 7触摸动画
EN

Stack Overflow用户
提问于 2009-11-14 10:04:51
回答 2查看 1.8K关注 0票数 1

在Windows7中,当你触摸屏幕时,触摸点会出现一个简短的动画。

在我的WPF应用程序中,我想显示我自己的触摸点,而不是显示Windows提供的触摸点。

对如何在应用程序中禁用它们有什么想法吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2010-04-17 14:35:45

今天在看Windows Touch的Surface Toolkit时发现了这一点,似乎做得很好。

代码语言:javascript
运行
复制
// 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);
}
票数 1
EN

Stack Overflow用户

发布于 2010-09-29 07:02:39

您可以在每个控件的基础上禁用它们,但最好的选择是,特别是对于您的特定情况,如果要在根应用程序的窗口和任何衍生窗口(包括弹出窗口)上执行此操作。将以下附加属性添加到XAML文件中的"“元素中,结果如下所示:

代码语言:javascript
运行
复制
<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将自动禁用这些功能(弹出窗口仍需手动处理)。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1732977

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档