[英]embededd application host in wpf
我想將一個應用程序設置為我的 WPF 應用程序的子應用程序。
我的應用程序有 3 個 window,我希望所有 windows 都成為 WPF 的孩子。
我使用此代碼在此處輸入代碼主要:
[DllImport("user32.dll")]
private static extern IntPtr SetParent(IntPtr hWnd, IntPtr hWndParent);
加載:
var helper = new WindowInteropHelper(this);
SetParent(proc.MainWindowHandle, helper.Handle);
它僅適用於 windows 之一。 我應該怎么做才能在 WPF 的孩子中擁有所有 windows?
WinForm 中的每個控件都有一個唯一的句柄,但 WPF 元素沒有,為了解決您的問題,您可以在 window 中放置一個或多個 WindowsFormsHost 並使用它們的句柄,因為每個 WindowsFormsHost 也具有與 WinForm 控件相同的唯一句柄。
然后像這樣使用 SetParent:
SetParent(proc.MainWindowHandle, YourWindowsFormsHost.Handle );
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.