wpf controls - To set the owner property for WPF window -


i working on creating addin autodesk inventor, have class lib project in show wpf window on button click, works great. however, not set owner property window.. in research came know need parent window object..

if you're not able parent window, can try setting parent using window handle.

i'm not familiar autodesk inventor , how create plugin application don't know if can window handle guess know process id or window caption/title or other information can parent window handle (you should google how window handle). once have handle of parent window can set owner of window using windowinterophelper.

here's sample how use windowinterophelper:

public partial class mainwindow : window {     public mainwindow()     {         initializecomponent();          intptr parentwindowhandler = intptr.zero;         // i'll notepad window can demonstrate (remember run notepad before running sample code :))         foreach (process plist in process.getprocesses())         {             if (plist.mainwindowtitle.contains("notepad"))             {                 parentwindowhandler = plist.mainwindowhandle;                 break;             }         }          var interop = new windowinterophelper(this);         interop.ensurehandle();         //         interop.owner = parentwindowhandler;          // i'll use check if owner set         // if it's set mainwindow shown @ center of notepad window         windowstartuplocation = system.windows.windowstartuplocation.centerowner;     } } 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -