Using a class derived from HwndHost
and some voodoo code:
protected override HandleRef BuildWindowCore(HandleRef hwndHost)
{
CheckGuestValidity();
var guestHwnd = new HandleRef(GuestHwnd, _guestHwnd);
Win32.SetWindowStyle(guestHwnd.Handle, WindowStyles.WS_CHILD | Win32.GetWindowStyle(guestHwnd.Handle));
WindowsFormsHost.EnableWindowsFormsInterop();
System.Windows.Forms.Application.EnableVisualStyles();
Win32.SetParent(guestHwnd.Handle, hwndHost.Handle);
Win32.SetWindowStyle(_guestHwnd, Win32.GetWindowStyle(_guestHwnd) & ~WindowStyles.WS_CAPTION);
return guestHwnd;
}
I have managed to get an otherwise parentless (except for Windows' main window) window from a Delphi COM server to adopt my WPF application window as it's parent window. Problem is it is located under all the other user controls etc. at the very bottom of my WPF window. I would like to size and position it to fit inside a rectangle on a tab in a TabControl. How can I go about this? I realise it will take a few resize and position Win32 API calls and maybe even a few low level Windows messages, but I'm up for it.