1

I've tried searching for the answer to this issue but I've been unlucky trying to find it.

From similar questions on here I've been able to make my transparent window receive mouse events, but then the other applications running behind it don't get any mouse events (Set the background of the window to #01000000 (mostly transparent)).

Or the alternative I've also achieved: the transparent window gets no mouse events and they are all passed through.

Is there a way to combine these 2 and have a transparent window that both interprets mouse events and passes them to whatever is behind it? My end goal would be to display a *ping* graphic on the transparent window (which is the same width/height of my desktop resolution) any time the mouse is clicked on the screen while I'm using other applications.

Further edit:

I have a Canvas in my WPF window. It has MouseLeftButtonDown as an element which calls a method in the behind-code. This method does not seem to get called when I use the solution that I linked, or when I simply set the Window and Canvas to Transparent or #00000000.

Community
  • 1
  • 1
gnil
  • 183
  • 1
  • 2
  • 10
  • I posted an answer on this question: `http://stackoverflow.com/questions/22452066/how-to-disable-hittesting-on-a-wpf-window/22456241#22456241` Does that help you? – Sourav 'Abhi' Mitra May 09 '14 at 05:48
  • @Abhi Yes, well, this is half of what I'm looking for. I think this looks like the same solution as the one I linked in the OP. I want to be able to interact with the applications behind the WPF window (which this solves), but I still want the WPF window to be able to capture/interpret/listen to mouse events. – gnil May 09 '14 at 05:55
  • i am not sure, but you may have to create a WNDPROC for this – Sourav 'Abhi' Mitra May 09 '14 at 06:18
  • Can you try something like this, Add a `WNDPROC`, first let the proc use the messages, then make the window transparent or mark `IsHitTestVisible = false`, and raise the same message again with `SendMessage` or `PostMessage` – Sourav 'Abhi' Mitra May 09 '14 at 06:38

1 Answers1

1

I think a better approach would be to use windows hook to catch global mouse events, and simply let your application discard mouse hit tests. As far as I know, Windows hook are not directly available in the .NET framework, but they are PInvokable.

Microsoft provides a pretty straightforward guide for this here.

Benlitz
  • 1,952
  • 1
  • 17
  • 30
  • 1
    Here's a link to a .NET library that helps you deal with gobal mouse hooks. http://www.codeproject.com/Articles/7294/Processing-Global-Mouse-and-Keyboard-Hooks-in-C – Mauro Sampietro May 09 '14 at 07:20
  • Using global hooks was the way to go - worked for me. Specifically, using the LowLevelMouseProc callback function associated with SetWindowsHookEx. Thanks. – gnil May 10 '14 at 03:55