l want set a SetParent in my WPF application,
but when l try to do that. it doesn’t work, l try it on the .net 8
the program where l want to set is calc.exe.
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
Process process = Process.Start("calc.exe");
// Find the handle of the external window
IntPtr externalWindowHandle = process.MainWindowHandle;
if (externalWindowHandle != null)
{
// Reparent the external window into the WPF application
SetParent(externalWindowHandle, new WindowInteropHelper(this).Handle);
}
else
{
MessageBox.Show("External window not found.");
}
}
l am expecting the view of calc.exe appear inside my wpf view
New contributor
casisa is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1