0

Hello, I was able to show the notepad in the Winform by using a panel and inserting it in the form like this code below and using SetParent API:

[DllImport("user32.dll", SetLastError = true)]
    static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);

Process proc = Process.Start(
    new ProcessStartInfo()
    {
                                                                                                              //here I put notepad.exe and it works 
        FileName = Environment.GetEnvironmentVariable("windir") + @"\system32\calc.exe", 
        WindowStyle = ProcessWindowStyle.Minimized
    });
            Thread.Sleep(200);

            SetParent(proc.MainWindowHandle, this.panel1.Handle);

My problem is for the calculator, I can't show the Calcultator in the winform it shows me an error.(System.InvalidOperationException)
Thank you.

2
Contributors
1
Reply
18
Views
1 Year
Discussion Span
Last Post by rproffitt
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.