title: Transparent form inexplicably passes only some touch inputs
body: <p>I have problems while I'm working where I'll pick up my laptop and since the screen is nearly the entire area of the laptops top portion, my hand ends up touching the screen and often minimizing or closing the program I'm working with. To remedy this, I made a small program I'm using to "disable" the touchscreen on my laptop, brought on by windows 10's lack of a disable option outside of device manager (on windows 7, you could just use the mouse settings - on win10 this option is gone). </p>
  
  <p>The program works well by essentially identifying and dropping mouse inputs identified as touches, but has a weird quirk in that a few windows still receive touch inputs, such as Edge and Chrome. Most programs don't have this problem and the program usually correctly drops the touch inputs. It's not a huge deal, but I'm wondering why those windows still receive inputs when others do not.</p>
  
  <p>I have attached the code (it's small), does anyone know why some programs still receive these inputs?</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.Windows.Forms;
  using System.Runtime.InteropServices;
  using System.Diagnostics;
  using System.Windows.Input;
  
  namespace TouchDisable
  {
      public partial class Form1 : Form
      {
          public Form1()
          {
              InitializeComponent();
              Width = Screen.PrimaryScreen.Bounds.Width;
              Height = Screen.PrimaryScreen.Bounds.Height;
              _hookID = SetHook(_proc);
          }
          private void Form1_FormClosed(object sender, FormClosedEventArgs e)
          {
              UnhookWindowsHookEx(_hookID);
          }
  
  
          //------------------------------------------------------------------------------------------
          private static LowLevelMouseProc _proc = HookCallback;
          private static IntPtr _hookID = IntPtr.Zero;
  
          private static IntPtr SetHook(LowLevelMouseProc proc)
          {
              using (Process curProcess = Process.GetCurrentProcess())
              using (ProcessModule curModule = curProcess.MainModule)
              {
                  return SetWindowsHookEx(WH_MOUSE_LL, proc,
                      GetModuleHandle(curModule.ModuleName), 0);
              }
          }
  
          private delegate IntPtr LowLevelMouseProc(int nCode, IntPtr wParam, IntPtr lParam);
  
          private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
          {
              if (IsTouch(lParam))
                  return new IntPtr(1);
              else
                  return CallNextHookEx(_hookID, nCode, wParam, lParam);
          }
  
          private const int WH_MOUSE_LL = 14;
  
          private enum MouseMessages
          {
              WM_LBUTTONDOWN = 0x0201,
              WM_LBUTTONUP = 0x0202,
              WM_MOUSEMOVE = 0x0200,
              WM_MOUSEWHEEL = 0x020A,
              WM_RBUTTONDOWN = 0x0204,
              WM_RBUTTONUP = 0x0205
          }
  
          [StructLayout(LayoutKind.Sequential)]
          private struct POINT
          {
              public int x;
              public int y;
          }
  
          [StructLayout(LayoutKind.Sequential)]
          private struct MSLLHOOKSTRUCT
          {
              public POINT pt;
              public uint mouseData;
              public uint flags;
              public uint time;
              public IntPtr dwExtraInfo;
          }
  
          [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
          private static extern IntPtr SetWindowsHookEx(int idHook,
              LowLevelMouseProc lpfn, IntPtr hMod, uint dwThreadId);
  
          [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
          [return: MarshalAs(UnmanagedType.Bool)]
          private static extern bool UnhookWindowsHookEx(IntPtr hhk);
  
          [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
          private static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode,
              IntPtr wParam, IntPtr lParam);
  
          [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
          private static extern IntPtr GetModuleHandle(string lpModuleName);
  
  
          //------------------------------------------------------------------------------------------
  
          const uint TOUCH_FLAG = 0xFF515700;
          static bool IsTouch(IntPtr lParam)
          {
              MSLLHOOKSTRUCT hookData = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam,
                  typeof(MSLLHOOKSTRUCT));
              uint extraInfo = (uint)hookData.dwExtraInfo.ToInt32();
              if ((extraInfo &amp; TOUCH_FLAG) == TOUCH_FLAG)
                  return true;
              return false;
          }
      }
  }
  
  </code></pre>