Stride: Get MouseWheel Delta from Window OR find out which window is on top

I am currently struggling to get the MouseWheel Delta from the InputSource of a Stride window.

It seems that getting the MouseWheel in Stride is only possible using InputManager, but that means that if you have several Stride Windows, you cannot know which window the mouse wheel delta came from. But that is kind of the point of using the InputSource coming out of the window, right?

The only node I could find is WheelDelta from the MouseWheelEvent class, but I don’t know how to get it from the iMouseDevice.

I looked at SplitMouseDevice that comes with the Stride Nuget and there its also simply using InputManager for the Mouse wheel delta:

So I need either one of these things:

  1. A way to get the mouse wheel delta from the Input Source of the Window
  2. Or a way to know which window the pointer is currently over (and which is in the foreground)

It basically needs to work that I can have 2 stride windows partly overlapping and it gets the mouse wheel delta only of the window that the cursor is over AND its the one in the foreground.

Okay, so I am already using Vanara.Pinvoke for some other stuff.

I found you can get the WindowHandle or HWND of a window.

There is the GetTopWindow function: GetTopWindow function (winuser.h) - Win32 apps | Microsoft Learn

This will get the windows of a parent or all windows if no parent is specified in Z-Order. Then we just need to find which of the windows comes first and that should be it.

I am currently stuck at getting the Window Handle (IntPtr) from a HWND, since GetTopWindow only outputs a HWND.

This is what I have currently:

Now I just need a way to convert HWND back to IntPtr.