diff --git a/src/Windows/Perspex.Win32/Embedding/EmbeddedWindowImpl.cs b/src/Windows/Perspex.Win32/Embedding/EmbeddedWindowImpl.cs
new file mode 100644
index 0000000000..accce44a88
--- /dev/null
+++ b/src/Windows/Perspex.Win32/Embedding/EmbeddedWindowImpl.cs
@@ -0,0 +1,64 @@
+namespace Perspex.Win32
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Runtime.InteropServices;
+ using System.Text;
+ using System.Threading.Tasks;
+ using System.Windows.Interop;
+ using Perspex.Win32.Interop;
+
+ public class EmbeddedWindowImpl : WindowImpl
+ {
+ private static readonly System.Windows.Forms.UserControl WinFormsControl = new System.Windows.Forms.UserControl();
+
+ public HwndHost Host { get; set; }
+
+ private class FakeHost : HwndHost
+ {
+ private readonly IntPtr hWnd;
+
+ public FakeHost(IntPtr hWnd)
+ {
+ this.hWnd = hWnd;
+ }
+
+ protected override HandleRef BuildWindowCore(HandleRef hwndParent)
+ {
+ UnmanagedMethods.SetParent(this.hWnd, hwndParent.Handle);
+ return new HandleRef(this, this.hWnd);
+ }
+
+ protected override void DestroyWindowCore(HandleRef hwnd)
+ {
+ }
+ }
+
+ public IntPtr Handle { get; private set; }
+
+ public HwndHost CreateWpfHost()
+ {
+ return new FakeHost(this.Handle);
+ }
+
+ protected override IntPtr CreateWindowOverride(ushort atom)
+ {
+ var hWnd = UnmanagedMethods.CreateWindowEx(
+ 0,
+ atom,
+ null,
+ (int)UnmanagedMethods.WindowStyles.WS_CHILD,
+ UnmanagedMethods.CW_USEDEFAULT,
+ UnmanagedMethods.CW_USEDEFAULT,
+ UnmanagedMethods.CW_USEDEFAULT,
+ UnmanagedMethods.CW_USEDEFAULT,
+ WinFormsControl.Handle,
+ IntPtr.Zero,
+ IntPtr.Zero,
+ IntPtr.Zero);
+ this.Handle = hWnd;
+ return hWnd;
+ }
+ }
+}
diff --git a/src/Windows/Perspex.Win32/Interop/UnmanagedMethods.cs b/src/Windows/Perspex.Win32/Interop/UnmanagedMethods.cs
index a8027513d8..0ffa2fbf5f 100644
--- a/src/Windows/Perspex.Win32/Interop/UnmanagedMethods.cs
+++ b/src/Windows/Perspex.Win32/Interop/UnmanagedMethods.cs
@@ -597,7 +597,8 @@ namespace Perspex.Win32.Interop
[DllImport("user32.dll")]
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, SetWindowPosFlags uFlags);
-
+ [DllImport("user32.dll")]
+ public static extern bool SetParent(IntPtr hWnd, IntPtr hWndNewParent);
[DllImport("user32.dll")]
public static extern bool ShowWindow(IntPtr hWnd, ShowWindowCommand nCmdShow);
diff --git a/src/Windows/Perspex.Win32/Perspex.Win32.csproj b/src/Windows/Perspex.Win32/Perspex.Win32.csproj
index 0346d8c28a..f04739410a 100644
--- a/src/Windows/Perspex.Win32/Perspex.Win32.csproj
+++ b/src/Windows/Perspex.Win32/Perspex.Win32.csproj
@@ -34,6 +34,8 @@
bin\Release\Perspex.Win32.XML
+
+
..\..\..\packages\Splat.1.6.2\lib\Net45\Splat.dll
True
@@ -42,6 +44,7 @@
+
@@ -59,6 +62,7 @@
..\..\..\packages\Rx-PlatformServices.2.2.5\lib\net45\System.Reactive.PlatformServices.dll
+
@@ -73,6 +77,7 @@
+
diff --git a/src/Windows/Perspex.Win32/Win32Platform.cs b/src/Windows/Perspex.Win32/Win32Platform.cs
index b96b9d5719..7884b7f05a 100644
--- a/src/Windows/Perspex.Win32/Win32Platform.cs
+++ b/src/Windows/Perspex.Win32/Win32Platform.cs
@@ -48,12 +48,10 @@ namespace Perspex.Win32
get { return TimeSpan.FromMilliseconds(UnmanagedMethods.GetDoubleClickTime()); }
}
- public static void Initialize()
+ private static void InitializeInternal()
{
var locator = Locator.CurrentMutable;
- locator.Register(() => new PopupImpl(), typeof(IPopupImpl));
- locator.Register(() => new WindowImpl(), typeof(IWindowImpl));
locator.Register(() => WindowsKeyboardDevice.Instance, typeof(IKeyboardDevice));
locator.Register(() => WindowsMouseDevice.Instance, typeof(IMouseDevice));
locator.Register(() => instance, typeof(IPlatformSettings));
@@ -61,6 +59,22 @@ namespace Perspex.Win32
locator.RegisterConstant(new AssetLoader(), typeof(IAssetLoader));
}
+ public static void Initialize()
+ {
+ var locator = Locator.CurrentMutable;
+ locator.Register(() => new PopupImpl(), typeof(IPopupImpl));
+ locator.Register(() => new WindowImpl(), typeof(IWindowImpl));
+ InitializeInternal();
+ }
+
+ public static void InitializeEmbedded()
+ {
+ var locator = Locator.CurrentMutable;
+ locator.Register(() => new EmbeddedWindowImpl(), typeof(IPopupImpl));
+ locator.Register(() => new EmbeddedWindowImpl(), typeof(IWindowImpl));
+ InitializeInternal();
+ }
+
public bool HasMessages()
{
UnmanagedMethods.MSG msg;
diff --git a/src/Windows/Perspex.Win32/packages.config b/src/Windows/Perspex.Win32/packages.config
index f4500fd3a2..b13c4f2ec8 100644
--- a/src/Windows/Perspex.Win32/packages.config
+++ b/src/Windows/Perspex.Win32/packages.config
@@ -1,10 +1,10 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
\ No newline at end of file