我需要将exe封装在我的wpf应用程序中。 我的wpf应用程序非常大,并有许多UserControls。 要做到这一点,我已经从我的代码启动exe,然后获取句柄,并使用“setParent”将exe绑定到我的应用程序,但唯一的影响是显示exe的下拉菜单,但不是主页面。例如:我试图嵌入记事本,但当我点击该区域时只出现下拉菜单(请注意,不出现在主菜单栏中)。在wpf中的c#exe封装不起作用
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);
请注意,我已经尝试在其他C#应用程序中的这段代码,并且工作正常! 我认为有重绘/更新视口的问题。 我可以用这种方法强制重新绘制我的应用程序中的外部exe文件? 你能帮助我,甚至找到一个替代解决方案来嵌入exe文件吗?由于
我试图运行在一个单独的标签(here)exe文件的解决方案,但即使这个解决方案行不通。
我可以使用“SendMessage”解决这个问题吗? 你能建议我做一个测试吗?
我问你一件事:帮帮我!
HTTP:/ /www.pinvoke.net/default.aspx/user32.RedrawWindow? – tolanj
或者这是Z指数的问题?我不是100%确定你正在努力实现什么...... – tolanj
http://www.pinvoke.net/default.aspx/user32/BringWindowToTop.html ?? – tolanj