Re: open vsta as a modal window...

  •  01-05-2007, 4:34 PM

    Re: open vsta as a modal window...

    Hi Pat,

    For complete control of the DTE you should consider creating an in-process host

    ms-help://MS.VSCC.v80/MS.VSIPCC.v80/MS.VSSDK.v80/dv_vstasdk/html/c10b7a28-074d-4450-99ba-d915dfd57a22.htm

    ===

    or try using the DTE.Events like

    ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_envdte/html/T_EnvDTE_Events_Members.htm

    as illustrated in ShapeAppAdvancedCSharp, extension.cs

    private void EnsureIDE()

    {

    if (this.dte == null)

    {

    try

    {

    IDTEProvider dteProvider = (IDTEProvider)new VSTADTEProviderClass();

    this.dte = (EnvDTE.DTE)dteProvider.GetDTE("ShapeAppAdvancedCSharp", 0);

    System.Diagnostics.Debug.Assert(this.dte != null);

    }

    catch

    {

    // If DTEProvider does not work, try co-creating DTE instead.

    object objDTE = new DTE();

    this.dte = (EnvDTE.DTE)objDTE;

    }

    // Save a copy of the event sync locations so they don't get

    // garbage collected.

    this.buildEvents = dte.Events.BuildEvents;

    this.solutionEvents = dte.Events.SolutionEvents;

    this.dteEvents = dte.Events.DTEEvents;

    this.buildEvents.OnBuildDone += new EnvDTE._dispBuildEvents_OnBuildDoneEventHandler(BuildEvents_OnBuildDone);

    this.solutionEvents.AfterClosing += new EnvDTE._dispSolutionEvents_AfterClosingEventHandler(solutionEvents_AfterClosing);

    this.dteEvents.OnBeginShutdown += new EnvDTE._dispDTEEvents_OnBeginShutdownEventHandler(dteEvents_OnBeginShutdown);

    }

    }

    Notice that the DTE object returned by VSTA's GetDTE() provides access to the Full VisualStudio Dev Environment.  The this.dteEvents.OnBeginShutdown event may be useful to you.

    See also

    ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_envdte/html/T_EnvDTE_DTE.htm

    and

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsintro7/html/vxlrfdteobject.asp

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsintro7/html/vxlrfonbeginshutdownevent.asp

    You will find more information about using this in the VS SDK and VS Extensibility forums

    Hope this helps.

    Regards,

    Gary

    Filed under: ,
View Complete Thread