Here's the basic code for putting the AppGameKit window into a panel in C#:
public MainForm()
{
InitializeComponent();
var p = Process.Start(agkExeFilepath);
if (p == null) return;
p.WaitForInputIdle();
SetParent(p.MainWindowHandle, panel1.Handle);
Agk.WindowHandle = p.MainWindowHandle;
}
[DllImport("user32.dll")]
private static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
Here's how I'm handling a resize event on the panel:
private void panel1_Resize(object sender, EventArgs e)
{
ResizeAgkWindow();
}
[DllImport("user32.dll")]
static extern bool MoveWindow(IntPtr handle, int x, int y, int w, int h, bool repaint);
private void ResizeAgkWindow()
{
MoveWindow(Agk.WindowHandle, 0, 0, panel1.Width, panel1.Height, true);
}
Here's what I use in AppGameKit to initialise the display settings:
function InitWindow()
global DeviceWidth as float
global DeviceHeight as float
SetWindowSize( GetMaxDeviceWidth() , GetMaxDeviceHeight() , 1 )
DeviceWidth = GetDeviceWidth()
DeviceHeight = GetDeviceHeight()
SetWindowSize( DeviceWidth, DeviceHeight, 1 )
SetVirtualResolution( DeviceWidth, DeviceHeight )
SetPrintSize(16)
UpdateWindow(1)
endfunction
Here is the AppGameKit code to update the window:
function UpdateWindow(force as integer)
if DeviceWidth<>GetDeviceWidth() or DeviceHeight<>GetDeviceHeight() or force=true
DeviceWidth = GetDeviceWidth()
DeviceHeight = GetDeviceHeight()
SetVirtualResolution( DeviceWidth, DeviceHeight )
endif
endfunction
The only other thing I can think of is to make sure you kill the Agk process if the form is closed.
That's enough to get an AppGameKit app into a panel, I'm still working on communication but text files seem to be working nicely now.
Any questions please ask!
EDIT: Here's a quick screenshot of my editor so far:
Using AppGameKit V2 Tier 1