I am converting Gleed2D from XNA to MonoGame.
Gleed2D is a Windows Form application that creates an instance of XnaGame . Then the window created by the Game is hidden, and DeviceWindowHandle set to Canvas in the main form.
I know that a little sip; the code speaks for itself: here it is completely .
The corresponding 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, Window.Handle can be added to Form . In MonoGame, it is implemented as OpenTK.GameWindow . How can I get into the actual window so that I can hide and / or resize it? . Alternative question: How can I create a MonoGame Game and say that the rendering surface belongs to another control?
source share