WPF opens an exe program in a WPF window

Not sure if this is possible, but is there a way to open another program, like notepad in a WPF window container? similar to being able to open a webpage using a web browser control?

Basically, I would like to open notepad or another exe, but save it in a WPF window container using xaml / C # code? not sure if possible?

+6
c # windows wpf
source share
3 answers

managed to do this using the SetParent method

[DllImport("user32.dll", SetLastError = true)] private static extern IntPtr SetParent(IntPtr hwc, IntPtr hwp); 

therefore, having received the descriptors for the wpf window and then the exe window, I was able to set the wpf window as the parent so that it would give an embed simulation (also closed the title, etc.)

got help from here: http://channel9.msdn.com/forums/TechOff/250417-Hide-window-caption-in-c/

+1
source share

Yes it is possible.

All you have to do is:

  • Create a WindowsFormsHost and add it to the panel in the user interface
  • Start a process (e.g. Notepad) using Process.Start
  • Call process.WaitForInputIdle
  • Use process.MainWindowHandle to get a window handle
  • Call SetWindowPos to set the process window to coordinates and Z Order the HwndHost window
  • Connect HwndHost and the process. MainWindowHandle to detect resizing and repeating step 5.

Absolutely easy to do it all. The effect is the full Notepad window (or any other application that you started), and behaves exactly as if it were part of your WPF application.

+6
source share

You cannot do this.

The reason you can browse the webpage is because IE was designed using an architecture that allows this - the rendering mechanism is not actually part of the actual IE executable, but the DLL that provides the component.

Generic EXEs do not work this way, and you cannot embed them in your application.

-one
source share

All Articles