© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
28 replies
Ossie

❔ WPF Window click-thru/non-clickable

Hey, how is it possible to make a WPF Window click-thru/non-clickable. I don't want to highlight or click on it in any way. The window is for an overlay, so I needs to be uninteractable, so you don't click it accidently.

I already tried the following without success:

1. Using SetWindowLong
[DllImport("user32.dll", EntryPoint = "SetWindowLongA", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);

[DllImport("user32.dll", EntryPoint = "GetWindowLongA", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern int GetWindowLong(IntPtr hWnd, int nIndex);

public const int WS_EX_TRANSPARENT = 0x00000020;
public const int GWL_EXSTYLE = (-20);

public static void MakeTransParent(IntPtr hWnd)
{
  int extendedStyle = GetWindowLong(hWnd, GWL_EXSTYLE);
  SetWindowLong(hWnd, GWL_EXSTYLE, extendedStyle | WS_EX_TRANSPARENT);
}
[DllImport("user32.dll", EntryPoint = "SetWindowLongA", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);

[DllImport("user32.dll", EntryPoint = "GetWindowLongA", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern int GetWindowLong(IntPtr hWnd, int nIndex);

public const int WS_EX_TRANSPARENT = 0x00000020;
public const int GWL_EXSTYLE = (-20);

public static void MakeTransParent(IntPtr hWnd)
{
  int extendedStyle = GetWindowLong(hWnd, GWL_EXSTYLE);
  SetWindowLong(hWnd, GWL_EXSTYLE, extendedStyle | WS_EX_TRANSPARENT);
}


This didn't work, and its still clickable for some reason. Is it because im trying to do it from inside the WPF windows own code?


2. IsHitTestVisible

I tried setting
IsHitTestVisible
IsHitTestVisible
to
false
false
, both in the XAML and after instancing the window. Still clickable...


Any help is appreciated, as I can't seem to find anything online that is not the methods listed above.


Thanks
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Making WPF window click thru / unclickable?
C#CC# / help
3y ago
Overlay (Not clickable and selectable window on top of fullscreen window) in WPF
C#CC# / help
4y ago
WPF Window Navigation
C#CC# / help
12mo ago
❔ wpf custom window
C#CC# / help
3y ago