How to remove white touch dot on windows 10

ⅰ亾dé卋堺 提交于 2019-12-24 02:02:47

问题


I am creating a kiosk like application for a Windows 10 PC with a touch screen as only interface for input. What I want to remove, is the white touch dot which is displayed as visual touch feedback (mostly together with a circle which can be turned off).

Has anyone an idea how to do this.

I have already searched the registry if there was a cursor (*.cur) file which is used but did not find any results. Due to that I guess that the touch feedback is displayed differently.

Just to make sure - I do not want to lose touch functionality, only the visual feedback needs to be gone.

Thanks in advance


回答1:


For WPF programs:

In order to remove the touch feedback from WPF elements, you have just to set Stylus.IsTapFeedbackEnabled dependency property to False. You could opt for styles:

<Style x:Key="yourStyle">
    <Setter Property="Stylus.IsTapFeedbackEnabled" Value="False" />
</Style>

The white touch dot you cited is, really, a cursor. When you touch the screen, Windows will override the cursor set for the control and it'll use the touch cursor, instead. To avoid this horrible behavior, you can set your cursor to Cursors.None, so that you'll hide the cursor. Paste the code below inside your Window and you won't see your white touch dot anymore.

protected override void OnPreviewTouchDown(TouchEventArgs e)
{
    base.OnPreviewTouchDown(e);
    Cursor = Cursors.None;
}

protected override void OnPreviewTouchMove(TouchEventArgs e)
{
    base.OnPreviewTouchMove(e);
    Cursor = Cursors.None;
}

protected override void OnGotMouseCapture(MouseEventArgs e)
{
    base.OnGotMouseCapture(e);
    Cursor = Cursors.Arrow;
}

protected override void OnPreviewMouseMove(MouseEventArgs e)
{
    base.OnPreviewMouseMove(e);
    if (e.StylusDevice == null)
        Cursor = Cursors.Arrow;
}

Your cursor will always be set to Cursors.Arrow when you use the mouse, though, so you could lose a different cursor you've set to the window, unfortunately.

For Windows Forms programs:

Looking at the Reference Source for Stylus.IsTapFeedbackEnabled, I found a way that doesn't seem to be appearing in any post. Here's how you can disable the touch/tap feedback in Windows Form applications:

using System;
using System.ComponentModel;
using System.Windows.Forms;

namespace TouchWinform
{

    public class TouchForm : Form
    {

        private const string TOUCH_SUPPORT_CATEGORY = "Touch support";
        private const bool IS_PRESS_AND_HOLD_ENABLED_DEFAULT_VALUE = false;
        private const bool IS_FLICKS_ENABLED_DEFAULT_VALUE = false;
        private const bool IS_TAP_FEEDBACK_DEFAULT_VALUE = false;
        private const bool IS_TOUCH_FEEDBACK_DEFAULT_VALUE = false;

        /// <summary>
        /// Gets or sets a values indicating whether press and hold is enabled.
        /// </summary>
        [Category(TOUCH_SUPPORT_CATEGORY), Description("Gets or sets a values indicating whether press and hold is enabled."), EditorBrowsable(EditorBrowsableState.Always), DefaultValue(IS_PRESS_AND_HOLD_ENABLED_DEFAULT_VALUE)]
        public bool IsPressAndHoldEnabled
        {
            get;
            set;
        } = IS_PRESS_AND_HOLD_ENABLED_DEFAULT_VALUE;

        /// <summary>
        /// Gets or sets a value indicating whether flicks are enabled.
        /// </summary>
        [Category(TOUCH_SUPPORT_CATEGORY), Description("Gets or sets a value indicating whether flicks are enabled."), EditorBrowsable(EditorBrowsableState.Always), DefaultValue(IS_FLICKS_ENABLED_DEFAULT_VALUE)]
        public bool IsFlicksEnabled
        {
            get;
            set;
        } = IS_FLICKS_ENABLED_DEFAULT_VALUE;

        /// <summary>
        /// Gets or sets whether a value indicating whether tap feedback is enabled.
        /// </summary>
        [Category(TOUCH_SUPPORT_CATEGORY), Description("Gets or sets whether a value indicating whether tap feedback is enabled."), EditorBrowsable(EditorBrowsableState.Always), DefaultValue(IS_TAP_FEEDBACK_DEFAULT_VALUE)]
        public bool IsTapFeedbackEnabled
        {
            get;
            set;
        } = IS_TAP_FEEDBACK_DEFAULT_VALUE;

        /// <summary>
        /// Gets or sets whether a value indicating whether touch feedback is enabled.
        /// </summary>
        [Category(TOUCH_SUPPORT_CATEGORY), Description("Gets or sets whether a value indicating whether touch feedback is enabled."), EditorBrowsable(EditorBrowsableState.Always), DefaultValue(IS_TOUCH_FEEDBACK_DEFAULT_VALUE)]
        public bool IsTouchFeedbackEnabled
        {
            get;
            set;
        } = IS_TOUCH_FEEDBACK_DEFAULT_VALUE;

        /// <summary>
        /// Processes Windows messages.
        /// </summary>
        /// <param name="m">The Windows <see cref="Message"/> to process.</param>
        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
                case 0x2CB:
                    m.Result = new IntPtr(1);
                    break;
                case 0x2CC:
                    uint flags = 0;
                    if (!IsPressAndHoldEnabled)
                        flags |= 1;
                    if (!IsTapFeedbackEnabled)
                        flags |= 8;
                    flags |= IsTouchFeedbackEnabled ? (uint)0x100 : 0x200;
                    if (!IsFlicksEnabled)
                        flags |= 0x10000;
                    m.Result = new IntPtr(flags);
                    break;
                default:
                    base.WndProc(ref m);
                    break;
            }
        }
    }
}

However, for some reason I don't understand, it's not actually working. If someone have got an idea, I'll hear it.



来源:https://stackoverflow.com/questions/48074613/how-to-remove-white-touch-dot-on-windows-10

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!