All pastes #636061 Raw Edit

Something

public text v1 · immutable
#636061 ·published 2007-07-27 16:10 UTC
rendered paste body
using System;
using Gtk;
using Gdk;
using System.Windows.Forms;
using System.Drawing;
using System.Threading;

namespace mwfingtk
{
	class MainClass
	{
		
		public static void Main (string[] args)
		{
			Gtk.Application.Init ();
			Gtk.Window gtkWindow = new Gtk.Window ("Title");
			gtkWindow.Add (new NativeContainer (InitializeMWF ().Handle));
			gtkWindow.Show ();
			
			Thread t = new Thread (Gtk.Application.Run); 
			t.Start ();
			while (!t.IsAlive) {};
		}
		
		private static Form _mwfContainer;
		
		private static Control InitializeMWF ()
		{
			_mwfContainer = new Form ();
			_mwfContainer.TopLevel = false;
			
			// run the MWF msg loop on a separate thread
			Thread t = new Thread (RunMWF); 
			t.Start ();
			while (!t.IsAlive) {};
			
			return _mwfContainer;
		}
			
		private static void RunMWF ()
		{
			_mwfContainer.ShowDialog ();
		}
	}
	
	public class NativeContainer : Gtk.Container
	{
		private IntPtr _childHandle;
		
		public NativeContainer (IntPtr childHandle)
		{
			_childHandle = childHandle;
		}
		
		protected override void OnRealized ()
		{
			base.OnRealized ();
			Gdk.Window.ForeignNew ((uint) _childHandle).Reparent (this.GdkWindow, 0, 0);
		}
	}
}