3

I am trying to develop a Windows application that allows people to "draw on their screen."

I’m developing with:

.NET 3.5 C#/WPF

I have a WPF Window that hosts an InkCanvas, both having transparent backgrounds.

Window XAML properties:

ShowInTaskbar="True" ResizeMode="NoResize" Background="Transparent"
WindowStyle="None" AllowsTransparency="True" Topmost="True"

InkCanvas properties:

Background="#11FFFFFF"

I need an event handler for the following: - right click anywhere in window - press escape

desired result: - WPF window remains on top of all other windows, but is no longer active and no longer accepts input - WPF window can longer be focused on. All input from the users should go to their current focused window and ignore the wpf window with the inkcanvas that is on top of everything

Basic usage example: A user of the app is playing a game. They stop and draw some arrows in the wpf window / inkcanvas. They finish by pressing escape. The wpf window remains on top, with the shapes the user drew open, and the user's input returns to whatever window they have open/focused.

So far, I've tried this:

MouseRightButtonUp ::   

mywindow.isenabled = false

and I've tried:

mywindow.IsInputMethodEnabled = false

Not working so far, the wpf window still starts grabbing user input. I somehow need to make this window as showing but without it being activated .. even after it has been "used" for some period of time.

Thank you in advance for any advice!

Alexander Perls
  • 123
  • 2
  • 9

1 Answers1

1

You can intercept the WndProc (using the AddHook of the HwndSource as shown here) and intercept the WM_NCHITTEST and return HTTRANSPARENT. That will only let it pass to other windows in that thread though. Another option might be to set the WS_EX_TRANSPARENT extended style bit. See this question's answer for an example.

Community
  • 1
  • 1
AndrewS
  • 6,054
  • 24
  • 31