title: Making a WPF window click-through, but not its controls
body: <p>First of all I want to define what I mean by <em>transparent to clicks</em> in the text bellow: It means the clicks go through my window without any processing, directly to whichever window is bellow it. I need this behaviour because this application is meant to be an overlay over a game.</p>
  
  <p>I searched the questions relating to making a window transparent to clicks. I was wondering if there was a way to make the window itself to be transparent to clicks, but not its controls (such as text boxes and buttons).</p>
  
  <p>Here is the markup for the window:</p>
  
  <pre><code>&lt;Window x:Class="QuestBrowser.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          Title="Quest Browser"
          Height="350" Width="525"
          AllowsTransparency="True" WindowStyle="None" Topmost="True"&gt;
      &lt;Window.Background&gt;
          &lt;SolidColorBrush Color="White" Opacity="0.1"/&gt;
      &lt;/Window.Background&gt;
      &lt;Grid&gt;
          &lt;Grid.RowDefinitions&gt;
              &lt;RowDefinition/&gt;
              &lt;RowDefinition/&gt;
          &lt;/Grid.RowDefinitions&gt;
          &lt;TextBox Name="inputTxtBox"&gt;&lt;/TextBox&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>And bellow is the code that makes the window transparent to clicks (pretty much copy-pasted from other question, because I'm not good at all at low level Windows programming).</p>
  
  <pre><code>namespace Win32Utils
  {
      public static class WindowHelper
      {
          const int WS_EX_TRANSPARENT = 0x00000020;
          const int GWL_EXSTYLE = (-20);
  
          public static void SetWindowExTransparent(IntPtr hwnd)
          {
              var extendedStyle = GetWindowLong(hwnd, GWL_EXSTYLE);
              SetWindowLong(hwnd, GWL_EXSTYLE, extendedStyle | WS_EX_TRANSPARENT);
          }
      }
  }
  </code></pre>
  
  <p>The method WindowHelper.SetWindowExTransparent is called from within my override of the method Window.OnSourceInitialized (as instructed in the post where I got the code for a transparent window from):</p>
  
  <pre><code>protected override void OnSourceInitialized(EventArgs e)
  {
      base.OnSourceInitialized(e);
      var hwnd = new WindowInteropHelper(this).Handle;
      WindowHelper.SetWindowExTransparent(hwnd);
  }
  </code></pre>
  
  <p>This does make the window transparent to clicks, but all controls I put into it are transparent as well (for example, the TextBox). Is there a way to make the Window surface transparent to clicks, but ensure the TextBox still receives mouse and keyboard input normally?</p>
  
  <p>I wanted to avoid mouse and keyboard hooks for both user privacy reasons and because, as I said, I don't understand much about the Windows API. If hooks are the only way, I would really appreciate a "For Dummies"-style explanation on how they work.</p>