dotnet / dotnet/wpf

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

Open
#3,145 1 comment 5 reactions 0 assignees View on GitHub
area-Touch Bug
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

* .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

```csharp
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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.