Problem with Mouse and Monogame in Winforms

I’ve embedded Monogame into a Windows Form using this code:

        private IntPtr drawSurface;
        private Control gameForm;
      
        public Game(MainWindow window)
        {
             graphics = new GraphicsDeviceManager(this);
             Content.RootDirectory = "Content";

             this.drawSurface = window.pcbViewport.Handle;
             graphics.PreparingDeviceSettings += new EventHandler<PreparingDeviceSettingsEventArgs>(graphics_PreparingDeviceSettings);
            Mouse.WindowHandle = drawSurface;
            gameForm = Control.FromHandle(this.Window.Handle);
            gameForm.VisibleChanged += new EventHandler(gameForm_VisibleChanged);
    }

    private void gameForm_VisibleChanged(object sender, EventArgs e)
    {
        if (gameForm.Visible)
        {
            gameForm.Visible = false;
        }
    }

    private void graphics_PreparingDeviceSettings(object sender, PreparingDeviceSettingsEventArgs e)
    {
        e.GraphicsDeviceInformation.PresentationParameters.DeviceWindowHandle = drawSurface;
    }

Now, this code used to work… I think. It’s been a while and the code is on another computer with an older version so I seem to remember this working before now with Monogame. Anyway, the problem is that Mouse input doesn’t work! Keyboard and Gamepad input work fine, but Mouse input doesn’t register at all. I’ve experimented and found that if I take out the VisibleChanged event, it works but it also shows the GameWindow as well as the form (which it doesn’t need to as it’s being drawn in the PictureBox.

I’m aware that I can put the GameWindow in a Control, and if need be then I’ll do that but I’m trying to see if there is a solution to making the existing code work again.

Monogame seems to be weird at compile with input… I have made a fully functional application on one computer and passed it to friends for only the input not to work for them… having another friend recompile the same monogame version(which be both installed the same day) had it working for me and everyone else… so you could try compiling it from another pc and see if that makes a difference.

No joy on that front… Just the same issue… I can only assume that because it thinks the GameWindow is not visible (which is true… sort of) then the Mouse is not detected! Which seems a bit dumb to me.

What you can try to do to diagnose it or rather where the problem starts… is put a breakpoint on the event that modifies the visible and see just when its being turned invisible…

but generally unless you have specificly made a modifier it should still track mouse movement and input even if its not set to visible…

After some help from StackOverflow it appears the problem is my method. the .Handle part of the GameWindow does nothing, it’s functionality has been removed from MonoGame and the property has been left for no reason other than to stop things breaking. Bah!

lol well at least you dont have to run like a chicken with its head cut off trying to figure out what the problem is anymore? XD