我想在傳統的win32應用程序中使用WPF窗口。 我想以類似的方式表現它們,比如WPF窗口總是顯示在win32窗口之上。如何將Win32窗口設置爲WPF窗口的所有者?
爲此,我想將WPF窗口的所有者設置爲win32窗口,但我不知道如何實現此目的。
這裏有什麼幫助嗎?
由於答案背後的一些鏈接,這裏隱藏該訣竅代碼:
System::Windows::Interop::WindowInteropHelper^ helper = gcnew System::Windows::Interop::WindowInteropHelper(myWpfChildWindow);
helper->Owner = (System::IntPtr)myMainWindowHWND;
是的,第二篇文章訣竅,簡稱以下幾行: System :: Windows :: Interop :: WindowInteropHelper^helper = gcnew System :: Windows :: Interop :: WindowInteropHelper(myWpfChildWindow); helper-> Owner =(System :: IntPtr)myMainWindowHWND; – Sam 2010-04-08 13:35:59
很高興你能工作! – 2010-04-08 15:58:08
這適用於.NET 4,但不適用於.NET 3.5。在.NET 3.5上,更改WindowInteropHelper的Owner屬性不起作用。有誰知道爲什麼,以及解決方法? – 2013-04-11 21:47:01