我已经创建了 WPF 应用程序。在这个应用程序中
- 我正在启动win form exe。
- 稍后将 WPF 窗口作为此 win 表单的父级。
- 当我以当前分辨率执行此应用程序时。一切正常
但是当我通过 4K Monitor(3840 * 2100) 启动相同的东西时,表单大小会减小。
我尝试了以下事情。
- 将 win 窗体大小设置为窗口。最大化。
- 创建 WPF 清单并取消注释 DPIaware 以使 WPF 应用程序 DPIaware。
- 操纵父窗口的大小。
任何帮助或建议都会有所帮助。(仅供参考:当我尝试从 WinForms 启动相同的 exe 时,我没有看到这个问题)。
代码片段
/* mainwindow.xaml.cs*/
var procInfo = new System.Diagnostics.ProcessStartInfo(ExeName, arguments);
// Start the process
var ProcessObj = System.Diagnostics.Process.Start(procInfo);
var helper = new WindowInteropHelper(Window.GetWindow(this.grid1));
SetParent(ProcessHandler, helper.Handle);
/* App.manifest */
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
</windowsSettings>
</application>
/*assemblyinfo.cs*/
[assembly: System.Windows.Media.DisableDpiAwareness]