There is a WPF window. It is necessary that the mouse click on the window passed under (behind) the window. That is, no matter what is under the window, another window, a bare desktop or something. A mouse click should be generated as if through a window. At the same time, the window itself should remain on top. Perhaps it is generally TopMost. Is it possible How?

  • Can SetCapture help you? ("Mouse" input focus, the window handle that the nearest mouse event will receive) is passed to the function) - nick_n_a
  • @nick_n_a, I do not understand how to use it in this case. It is also necessary to find out what the window is behind my window under the cursor. In addition, there may not be a window at all - iRumba
  • one
    If you want a window full of holes, you need the SetWindowRgn function and create the region of the desired form Regions and for c # here - nick_n_a
  • @nick_n_a, is it possible in more detail? - iRumba
  • one
    @iRumba: Maybe it will work: stackoverflow.com/q/1524035/276994 ? - VladD

1 answer 1

If this behavior is needed unconditionally, for this element IsHitTestVisible = "False", making it "invisible" for the mouse.

This implies some kind of control, this behavior is called event propagation in the general case, in the case of WFP - event routing (event routing, the term that came from MFC). For example, there are Preview *** events where, when the Handled flag is changed in RoutedEventArgs, you can disable stopping the passing of the event.

About event routing: https://msdn.microsoft.com/en-us/library/ms742806.aspx

  • In general, the window does not work out with this through - iRumba
  • @iRumba in which case and explain your term "pass-through." If "do not receive events" - then this is IsHitTestVisible. If it is necessary to process and transmit further, then it is necessary to do the marshaling corresponding to the required scheme - Swift
  • one
    @Swift: meaning, apparently, that the whole window is transparent for mouse events, i.e., the click is transmitted to another window . - VladD
  • @VladD, yes, you are right. And I wrote that way. Maybe you have an idea how to do this? - iRumba
  • @iRumba: I think we need the regions mentioned in the comments. - VladD