i have this code which for now let me open notepad.exe inside a wpf window, the problem is when i open the window i see the notepad but not in full size inside the window, hope someone can help, thanks :
/// <summary>
/// Interaction logic for windows1.xaml
/// </summary>
public partial class windows1 : Window
{
public IntPtr MainWindowHandle { get; set; }
[DllImport("user32.dll", SetLastError = true)]
private static extern long SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
//[DllImport("user32.dll", SetLastError = true)]
//private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
public windows1()
{
InitializeComponent();
try
{
//External exe inside WPF Window
System.Windows.Forms.Panel _pnlSched = new System.Windows.Forms.Panel();
WindowsFormsHost windowsFormsHost1 = new WindowsFormsHost();
windowsFormsHost1.Child = _pnlSched;
this.gridtest.Children.Add(windowsFormsHost1);
ProcessStartInfo psi = new ProcessStartInfo("notepad.exe");
psi.WindowStyle = ProcessWindowStyle.Maximized;
Process PR = Process.Start(psi);
// true if the associated process has reached an idle state:
PR.WaitForInputIdle();
//System.Threading.Thread.Sleep(3000);
IntPtr hwd = PR.MainWindowHandle;
// loading exe to the wpf window:
SetParent(PR.MainWindowHandle, _pnlSched.Handle);
}
catch (Exception ex)
{
//Nothing...
}
}
}