I'm converting Gleed2D from XNA to MonoGame.
Gleed2D is a Windows Form application that instantiates an XnaGame
. The window
created by the Game
is then hidden and the DeviceWindowHandle
is set to that of a Canvas
on the main form.
I know that's a bit of a mouthful; the code speaks for itself: here it is in full.
The relevant bits are in the constructor:
_drawSurface = mainForm.GetHandleToCanvas();
_graphics = new GraphicsDeviceManager( this )
{
PreferredBackBufferWidth = 800,
PreferredBackBufferHeight = 600
} ;
_graphics.PreparingDeviceSettings += graphics_PreparingDeviceSettings;
_winform = (Form)Form.FromHandle(Window.Handle);
_winform.VisibleChanged += game1VisibleChanged;
_winform.Size = new Size(10, 10);
Mouse.WindowHandle = _drawSurface;
Size pictureBoxSize = _mainForm.CanvasSize ;
ResizeBackBuffer( pictureBoxSize.Width, pictureBoxSize.Height ) ;
... some other stuff....
void graphics_PreparingDeviceSettings(object sender, PreparingDeviceSettingsEventArgs e)
{
e.GraphicsDeviceInformation.PresentationParameters.DeviceWindowHandle = _drawSurface;
}
My question is: In XNA, the Window.Handle
can be cast to a Form
. In MonoGame, it's implemented as an OpenTK.GameWindow
. How can I get to the actual window so that I can hide and/or resize it?. An alternative question would be: How can I create a MonoGame Game
and tell it the render surface is that of another control?