locked
SDK package set owner of Dialog in wpf RRS feed

  • Question

  • hi

    I have a package with a dialog box in WPF.  I want to set the owner of my dialog box. I can get the main window from the EnvDTE.DT2 but not have it in the good type.

    I'm using Visual Studio 2008 .NET 3.5 sp1. I know in VS2010 the DialogWindow does it automatically for me. How i can get the main window or the active window in 2008?

    thanks

    Thursday, August 18, 2011 3:04 PM

Answers

  • 2010 can do this because the top level window is a WPF Window type, in 2008 that is not the case, therefore you can't parent a WPF window to the main windows HWND via WPF in any way I am aware of.  You likely need to pInvoke to SetParent.

    Ryan

    Thursday, August 18, 2011 3:29 PM

All replies

  • You should derive your dialog from DialogWindow and then call ShowModal() on it. It will do all the work of setting the owner, preparing VS for a modal state, etc...

    Regards,
    Aaron


    http://blogs.msdn.com/aaronmar
    Thursday, August 18, 2011 3:28 PM
  • 2010 can do this because the top level window is a WPF Window type, in 2008 that is not the case, therefore you can't parent a WPF window to the main windows HWND via WPF in any way I am aware of.  You likely need to pInvoke to SetParent.

    Ryan

    Thursday, August 18, 2011 3:29 PM
  • Ack....Ryan has the better answer. :)  I missed the part about this being on 2008.
    http://blogs.msdn.com/aaronmar
    Thursday, August 18, 2011 3:30 PM
  • Thanks for your response. I will try this solution.
    Thursday, August 18, 2011 6:23 PM