2009-11-14 28 views
1

在Windows 7中,當您觸摸屏幕時,在觸摸點上會出現一個短的動畫。禁用WPF中的Windows 7觸摸動畫

在我的WPF應用程序中,我想顯示自己的接觸點,而不顯示Windows提供的接觸點。

有關如何在應用中禁用它們的任何想法?

回答

1

今天發現這一點,同時看看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); 
} 
4

您可以在每個控制基礎上禁用它們,但最好的選擇,專爲您的特定情況下,如果要做到這一點根應用程序的窗口上,任何衍生窗口(包括彈出窗口)。下面的附加屬性添加到您的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將自動禁用這些給你(彈出窗口仍然必須手動處理)。