DCSIMG
IWin32Window Owner For WPF Window - Shai Raiten's Blog

Shai Raiten's Blog

It's all about code...

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 -

Form1.Show(this);

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.

Posted: Jan 16 2009, 01:19 AM by shair | with 2 comment(s)
תגים:, , ,

Comments

DotNetKicks.com said:

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# January 16, 2009 1:06 PM

R4 Cards said:

I am glad to talk with you and you give me great help! Thanks for that,I am wonderring if I can contact you via email when I meet problems.

# February 5, 2010 11:20 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Enter the numbers above: