How do I disable Windows 8 touch contact visualizations for my application?

Raymond Chen

You might have an application (like a game) where the default touch contact visualizations are a distraction. In WinRT, you can disable the contact visualizations by simply saying

// JavaScript
Windows.UI.Input.PointerVisualizationSettings.
    getForCurrentView().
    isContactFeedbackEnabled = false;
// C#
Windows.UI.Input.PointerVisualizationSettings.
    GetForCurrentView().
    IsContactFeedbackEnabled = false;
// C++
Windows::UI::Input::PointerVisualizationSettings::
    GetForCurrentView()->
    IsContactFeedbackEnabled = false;

In Win32, you use the Set­Window­Feedback­Setting function. To demonstrate that, let’s take our scratch program and make this simple change:

BOOL
OnCreate(HWND hwnd, LPCREATESTRUCT lpcs)
{
 BOOL fEnabled = FALSE;
 SetWindowFeedbackSetting(hwnd,
    FEEDBACK_TOUCH_CONTACTVISUALIZATION,
    0, sizeof(fEnabled), &fEnabled);
 return TRUE;
}

The touch visualizations are white and the default window color is white, so the visualizations are hard to see in the scratch program. Let’s change the color to something that the visualizations will be more visible against.

    wc.hbrBackground = (HBRUSH)(COLOR_WINDOWTEXT + 1);

Run the program, and you’ll see that if you touch the window and drag your finger around, there is no little white circle and no white streak that follows your finger. (Note, however, that the Optimize visual feedback for projection to an external monitor, setting overrides the FEEDBACK_TOUCH_CONTACT­VISUALIZATION setting, so if you have projection contacts enabled, then you still get the dark circles. Another way to get dark circles is to stay up late and not get enough sleep.)

Although we disabled contact visualizations, we still get visualizations for gestures like tap or tap-and-hold. We can turn those off, too:

BOOL
OnCreate(HWND hwnd, LPCREATESTRUCT lpcs)
{
 BOOL fEnabled = FALSE;
 SetWindowFeedbackSetting(hwnd,
    FEEDBACK_TOUCH_CONTACTVISUALIZATION,
    0, sizeof(fEnabled), &fEnabled);
 SetWindowFeedbackSetting(hwnd,
    FEEDBACK_TOUCH_TAP,
    0, sizeof(fEnabled), &fEnabled);
 SetWindowFeedbackSetting(hwnd,
    FEEDBACK_TOUCH_DOUBLETAP,
    0, sizeof(fEnabled), &fEnabled);
 SetWindowFeedbackSetting(hwnd,
    FEEDBACK_TOUCH_PRESSANDHOLD,
    0, sizeof(fEnabled), &fEnabled);
 SetWindowFeedbackSetting(hwnd,
    FEEDBACK_TOUCH_RIGHTTAP,
    0, sizeof(fEnabled), &fEnabled);
 return TRUE;
}

The complete list of things you can disable is given by the FEEDBACK_TYPE enumeration.

0 comments

Discussion is closed.

Feedback usabilla icon