I need to encapsulate exe on my wpf application. My wpf application is very large and with many UserControls. To do this, i've start the exe from my code, then get the handle and used the "setParent" to "bind" the exe to my application, but the only effect is to show the drop down menu of the exe, but not the main page. For example: i've tried to embedded notepad, but appear only the drop down menu when I click in the area (note that not appear the main menu bar).
var procInfo = new System.Diagnostics.ProcessStartInfo(this.exeName);
procInfo.WorkingDirectory = System.IO.Path.GetDirectoryName(this.exeName);
// Start the process
_childp = System.Diagnostics.Process.Start(procInfo);
// Wait for process to be created and enter idle condition
_childp.WaitForInputIdle();
// Get the main handle
_appWin = _childp.MainWindowHandle;
// Get main window handle
var helper = new WindowInteropHelper(Window.GetWindow(this.AppContainer));
// Incapsulate
SetWindowLongA(_appWin, -20, 0x00000040 | 0x00000008);
SetParent(_appWin, helper.Handle);
Note that I've tried this piece of code in other c# application and work fine! I think there is a problem of redraw/update the viewport. In which way can i force this redraw of the external exe inside my application? Can you help me, even to found an alternative solution to embedded the exe? Thanks
I've tried the solution to run the exe in a separate tab (here), but even this solution not work.
Can I resolve this with a "SendMessage" ??? Can you suggest me a test to do?
I ask you one thing: help me!!!
The below works for me, can provide you with example project if necessary. The missing piece seems to be that either you have a z index issue OR your initial window placement in your desktop co-oridinates is such that is it outside your 'outer window'.
this will bring it the the from and make it FILL your window:
The default(IntPtr) is for the ZIndex and says 'bring to front'
You can then make that smaller by passing in the offsets from your containing control, ie if
this.grid
was what you wanted notepad to appear over: