I am trying to find a way to create a transparent overlay that I can put anywhere on the screen, but that does not stop keystrokes and mouse events from passing through.
If you have ever seen the program Camtasia, they do it... when you define a portion of the screen, they drop a shadowed gradient over the screen, and as you drag a rectangle, it "cut's away" the gradient. But, even though the screen has the shadow layer, everything is still clickable and usable. It is a visual effect that doesn't seem to alter the functionality of any program.
I have done something that ALMOST works. I have a form that I set the opacity down on, and then I use the GetWindowLong function to set a transparent pass-through style. But it won't work for every application. For example, a drawing program won't work when I have the overlay up.
But... in Camtasia, everything still works fine... so they must know some mojo I don't... Anyone have any ideas?
The code I am using is:
[DllImport("user32.dll", SetLastError = true)] static extern int GetWindowLong(IntPtr hWnd, int nIndex); [DllImport("user32.dll", SetLastError = true)] static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong); private const int GWL_EXSTYLE = -20; private const int WS_EX_TRANSPARENT = 0x20; ... int exstyle = GetWindowLong(this.Handle, GWL_EXSTYLE); exstyle |= WS_EX_TRANSPARENT; SetWindowLong(this.Handle, GWL_EXSTYLE, exstyle);