IWin32Window Owner For WPF Window
IWin32Window Owner For WPF Window
I wrote a Word Plugin in WPF, when raise the window with ShowDialog it’s seems that all Word instances on the computer stucks, even new ones.
So I need to open My window just for a specific Word instance.
In Windows Form you can write -
But in WPF you need to use WindowInteropHelper.
//Create WPF Window
MainUI1 win = new MainUI1();
WindowInteropHelper helper = new WindowInteropHelper(win);
//Find Current Word Process
Process procs = Process.GetCurrentProcess();
//Get the handle from the process
IntPtr hwnd = procs.MainWindowHandle;
//Set Word handle to helper
helper.Owner = hwnd;
win.Show();
Hope this helps.