locked
ToolWindows from VisualStudio start page RRS feed

  • Question

  • Hi,

    I'm try to open a ToolWindow from my Custom Visual Studio start page. I use this code:

     ServiceProvider serviceProvider = Utilities.GetServiceProvider(DTE);
                IVsUIShell shell = (IVsUIShell)serviceProvider.GetService(typeof(SVsUIShell));
    
                Guid myWindowGuid = typeof(MyToolWindow).GUID;
                IVsWindowFrame frame = null;
     
                int result = shell.FindToolWindow((uint)__VSFINDTOOLWIN.FTW_fForceCreate, ref myWindowGuid, out frame);
    


    But the 'frame' variable is always null. Is it possible to something like this or tool windows can be opened only from pacakges and add-ins?

    Thanks in advance.

    Thursday, December 8, 2011 1:34 PM

Answers

  • Hi again,

    I think that I done it.

    Shortly I use CreateToolWindow instead of FindToolWindow

    Here is my code:

     

    ServiceProvider serviceProvider = Utilities.GetServiceProvider(DTE);
                IVsUIShell shell = (IVsUIShell)serviceProvider.GetService(typeof(SVsUIShell));
                IVsWindowFrame frame = null;
    
                Guid guid1 = Guid.Empty;
                Guid guid2 = new Guid("8D018420-2240-11E1-95AC-96C44824019B");
                Guid guid3 = Guid.Empty;
    
                shell.CreateToolWindow((uint)__VSCREATETOOLWIN.CTW_fForceCreate, 0, new MyToolWindow(),ref guid1,
                                     ref guid2, ref guid3, null,
                                       "Test window",
                                       null,out frame);
    
                frame.SetProperty((int)__VSFPROPID.VSFPROPID_FrameMode, VSFRAMEMODE.VSFM_Float);
                frame.Show();
    


    The guid2 variable has the value of the Guid attribute of the MyToolWindow class.

    Thanks for the help anyway.

     

    Friday, December 9, 2011 10:06 AM

All replies

  • No, there is no special logic that would somehow know you are 'in a package or add-in'.  If you have the service you can do anything with it. What is result? Are you sure MyToolWindow.GUID is the proper GUID and the toolwindow has been properly registered?

    Ryan

    Thursday, December 8, 2011 3:36 PM
  • Hi,

    Thank you very much for your answer.

    I'm not sure how to register the toolwindow. I saw an example in the Visual Studio SDK samples and I think that it dosen't require any registration. Otherwise the FindToolWindow method returns -2147467261 (the 'result' variable in my code).

    Thanks for the help.

    Friday, December 9, 2011 7:24 AM
  • Hi again,

    I think that I done it.

    Shortly I use CreateToolWindow instead of FindToolWindow

    Here is my code:

     

    ServiceProvider serviceProvider = Utilities.GetServiceProvider(DTE);
                IVsUIShell shell = (IVsUIShell)serviceProvider.GetService(typeof(SVsUIShell));
                IVsWindowFrame frame = null;
    
                Guid guid1 = Guid.Empty;
                Guid guid2 = new Guid("8D018420-2240-11E1-95AC-96C44824019B");
                Guid guid3 = Guid.Empty;
    
                shell.CreateToolWindow((uint)__VSCREATETOOLWIN.CTW_fForceCreate, 0, new MyToolWindow(),ref guid1,
                                     ref guid2, ref guid3, null,
                                       "Test window",
                                       null,out frame);
    
                frame.SetProperty((int)__VSFPROPID.VSFPROPID_FrameMode, VSFRAMEMODE.VSFM_Float);
                frame.Show();
    


    The guid2 variable has the value of the Guid attribute of the MyToolWindow class.

    Thanks for the help anyway.

     

    Friday, December 9, 2011 10:06 AM