What am i saying? It isn't restricted to only MDI Forms. .Net controls are essentially windows, and so also expose a handle. I've now got the engine rendering into a Panel control. This gives you a bit more control.
Well here is how you do it...
First you need the Interop namespace...
using System.Runtime.InteropServices;
Now you need to define the Win32 constants and functions...
const int WS_VISIBLE = 0x10000000;
const UInt32 SWP_SHOWWINDOW = 0x0040;
[DllImport("user32.dll")]
static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
[DllImport("user32.dll")]
static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
[DllImport("user32.dll")]
static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
Now basically you create a control inside your form. A Panel is a simple one.
Then you call these 3 functions. You should use the Form's 'Shown' event to execute this...
a7.EngFun.engine_open(null);
a7.EngFun.engine_frame(); // Required else crash (D3D isnt loaded yet)
SetParent(a7.EngVar.hWnd, MyPanel.Handle);
SetWindowLong(a7.EngVar.hWnd, -16, WS_VISIBLE);
SetWindowPos(a7.EngVar.hWnd, (IntPtr)0, 0, 0, MyPanel.Width, MyPanel.Height,
SWP_SHOWWINDOW);
while (a7.EngFun.engine_frame() != 0)
{
}
That's pretty much it. I've created my own control derived from Panel, and wrapped everything inside it.
There are a couple of issues with setting focus to the parent that i'm gonna look into later on today, and i'll update this post.
BTW > WTF is wrong with the forum? Everytime i type something it jusmps to the first line? I've noticed this for a while but now it's getting really annoying!!!