Let hit-test messages pass on through Xaml Islands window with a custom window. RRS feed

  • Question

  • I have a custom window on which I have removed the borders and the standard DWM frame from. I created a Xaml Islands window to take up the entire client area. I am now creating a Xaml titlebar. I want the click events to fall back to the main window so that it can move, not just the title bar. I have tried about everything:

    WS_EX_TRANSPARENT on the XamlIslandWindow and WS_DISABLED - this works, but since the Xaml islands window does not receive any input, buttons don't click, etc.

    Handle PointerPressed on my titleBarGrid:

    SendMessageW(MainWindow, WM_NCLBUTTONDOWN, HTCAPTION, 0)

    SendMessageW(MainWindow, WM_SYSCOMMAND, HTCAPTION | SC_MOVE, MAKELPARAM(p.x, p.y))

    I have also tried to subclass the Xaml window but that doesn't work either. However, when I try to subclass the input window, I receive messages, but as soon as I call the original window procedure, the app throws an exception.

    Does anybody know how to make this work?

    Sunday, September 29, 2019 8:28 PM

All replies

  • Check if you can apply the next thoughts:

    • It is possible to set IsHitTestVisible=“False”, but this probably is not applicable for your scenario.
    • In case of items that have HWND, the messages can be intercepted using HwndSource and OnSourceInitialized  ( If you can intercept WM_NCHITTEST in your bar, check the mouse coordinates and return HTTRANSPARENT instead of leaving the message unhandled, then the message should be theoretically sent to underlaying window.
    • In the main window (native or WPF), if you intercept WM_NCHITTEST, check the coordinates and return HTCAPTION, this should instruct the Windows to perform the movement. (In case of native window, instead of checking the coordinates, you can call the default handler and replace HTCLIENT etc. with HTCAPTION).
    • If you have a small sample project, then maybe you can publish it (on OneDrive, for example).
    Monday, September 30, 2019 6:56 AM