@dryhfth Thanks for showing I am sorry I don’t see link about your example picture.
I have tried . But It seems like crazy.
If I use GetWindow() from User32.dll for Windows only
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using OpenTK;
using OpenTK.Graphics.OpenGL;
using System;
using System.Runtime.InteropServices;
namespace MonoCrraft
{
public abstract class SubGameWindow : OpenTK.GameWindow, IGraphicsDeviceService
{
private static GraphicsDevice graphicsDevice;
private static Color clearColor;
private static PresentationParameters presentationParameters;
// For Windows
[DllImport("User32")]
private static extern IntPtr GetTopWindow(IntPtr hWnd);
[DllImport("user32.dll", SetLastError = true)]
private static extern IntPtr GetWindow(IntPtr hWnd, GetWindow_Cmd uCmd);
public enum GetWindow_Cmd : uint
{
GW_HWNDFIRST = 0,
GW_HWNDLAST = 1,
GW_HWNDNEXT = 2,
GW_HWNDPREV = 3,
GW_OWNER = 4,
GW_CHILD = 5,
GW_ENABLEDPOPUP = 6
}
public SubGameWindow(IntPtr Parent)
{
presentationParameters = new PresentationParameters();
presentationParameters.BackBufferWidth = Width;
presentationParameters.BackBufferHeight = Height;
graphicsDevice = new GraphicsDevice(GraphicsAdapter.DefaultAdapter, GraphicsProfile.HiDef, presentationParameters);
GetWindow(Parent, GetWindow_Cmd.GW_OWNER);
}
public GraphicsDevice GraphicsDevice
{
get
{
return graphicsDevice;
}
}
public Color ClearColor
{
get
{
return clearColor;
}
set
{
clearColor = value;
}
}
public event EventHandler<EventArgs> DeviceCreated;
public event EventHandler<EventArgs> DeviceDisposing;
public event EventHandler<EventArgs> DeviceReset;
public event EventHandler<EventArgs> DeviceResetting;
protected override void OnLoad(EventArgs e)
{
LoadContent();
base.OnLoad(e);
}
protected override void OnUpdateFrame(FrameEventArgs e)
{
Update();
base.OnUpdateFrame(e);
}
protected override void OnRenderFrame(FrameEventArgs e)
{
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit);
GL.ClearColor(ClearColor.R, ClearColor.B, ClearColor.G, ClearColor.A);
graphicsDevice.Clear(ClearColor);
Draw();
base.OnRenderFrame(e);
SwapBuffers();
}
protected override void OnResize(EventArgs e)
{
GL.Viewport(graphicsDevice.Viewport.Bounds.X, graphicsDevice.Viewport.Bounds.Y, graphicsDevice.Viewport.Bounds.Width, graphicsDevice.Viewport.Bounds.Height);
base.OnResize(e);
}
protected abstract void LoadContent();
protected abstract void Update();
protected abstract void Draw();
}
}
SettingWindow with SubGameWindow.cs
using Microsoft.Xna.Framework;
using System;
namespace MonoCrraft
{
/**
* It is simple setting window
*/
public class SettingWindow : SubGameWindow
{
MyGame MyGame;
public SettingWindow(IntPtr Parent) : base(Parent)
{
Width = 300;
Height = 300;
Visible = true;
}
protected override void LoadContent()
{
}
protected override void Update()
{
}
protected override void Draw()
{
GraphicsDevice.Clear(Color.CornflowerBlue);
}
}
}
And MyGame.cs with SettingButton:
private void SettingHandler(object sender, EventArgs e)
{
var setWin = new SettingWindow(Window.Handle);
setWin.Run(60);
}
Than It looks ugly… If I close sub window than sub window moves to main window. I really don’t understand. But i really want fix that MonoGame’s Game.cs should catch / own to sub / child windows. . I think I need resolve…