Skip to content

WPF can not receive the touch message when set WS_EX_TRANSPARENT to window #3145

Open

Description

@lindexi
  • .NET Core Version: 3.1.300
  • Windows version: 10.0.18362
  • Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes

Problem description:

WPF can not receive the touch message when set WS_EX_TRANSPARENT to window

We can create an empty WPF application, and then we can output message when we receive the mouse down and touch down event

But when we set the WS_EX_TRANSPARENT property to the window, that we can find that we can only receive the mouse event and can not receive the touch event

        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            IntPtr hwnd = new WindowInteropHelper(this).Handle;
            var extendedStyle = GetWindowLong(hwnd, GWL_EXSTYLE);
            SetWindowLong(hwnd, GWL_EXSTYLE, extendedStyle | WS_EX_TRANSPARENT);
        }

Actual behavior:

We can not receive the touch event and we only receive the mouse event

Expected behavior:

We can receive the touch event just like the mouse behavior

Minimal repro:

https://github.com/dotnet-campus/wpf-issues/tree/master/CanNotReceiveTouchMessageWS_EX_TRANSPARENT

Activity

  1. weltkante commented on Jun 15, 2020

    @weltkante

    WS_EX_TRANSPARENT provides hittest transparency, which means the window is "click through". Not reporting touch events should be expected behavior? I doubt WPF can do anything here, can you confirm this is WPF specific and native applications receive touch input when setting this flag?

  2. added
    Bug
    on Jun 15, 2020
  3. added this to the Future milestone on Jun 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugarea-Touch

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions