Skip to content

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

Open
@lindexi

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugProduct bug (most likely)

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions