How can I make my Labels click through, IsHitTestVisible doesn't work (WPF)

0

Solution by Andy

protected override void OnSourceInitialized(EventArgs e)
{
  // Get this window's handle         
  IntPtr hwnd = new WindowInteropHelper(this).Handle;
  // Change the extended window style to include WS_EX_TRANSPARENT         
  int extendedStyle = GetWindowLong(hwnd, GWL_EXSTYLE);
  SetWindowLong(hwnd, GWL_EXSTYLE, extendedStyle | WS_EX_TRANSPARENT);  
  base.OnSourceInitialized(e);
}
public const int WS_EX_TRANSPARENT = 0x00000020;   public const int GWL_EXSTYLE = (-20);   

[DllImport("user32.dll")]
public static extern int GetWindowLong(IntPtr hwnd, int index);

[DllImport("user32.dll")]
public static extern int SetWindowLong(IntPtr hwnd, int index, int newStyle); 

I have the following problem, I have a transparent Form, where I have a bunch of labels on to enter code here`how me Information while I'm playing. My Problem now is, that when I'm moving the Mouse while I'm playing the Mouse Cursor gets onto one of the labels and moves the focus to the form instead of the game. I tried setting IsHitTestVisible to false, but it's still not click through!

I also tried to apply IsHitTestVisible to all labels, still won't work.

c#
wpf
asked on Stack Overflow Dec 27, 2019 by TRINIOX • edited Dec 28, 2019 by TRINIOX

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0