Hi,
Is it possible to open a misc document from a ToolWindow?
It seems I should be able to use the method
VsShellUtilities.OpenDocumentWithSpecificEditor, but I don't really have a
IServiceProvider in the ToolWindow.
Can anyone help?
Thanks,
Shirley
"Gary Chang[MSFT]" - 08 Sep 2005 10:49 GMT
Hi Shirley,
>It seems I should be able to use the method
>VsShellUtilities.OpenDocumentWithSpecificEditor,
>but I don't really have a IServiceProvider in the ToolWindow.
Based on my understanding, you need to create a specific editor in your
package's ToolWindow to open a misc document, please correct me know if I
have misunderstood anything.
If so, since your ToolWindow class doesn't have an IServiceProvider
interface, but its parent package has it, how about use the package's
IServiceProvider to get the VsShellUtilities object...
Thanks!
Best regards,
Gary Chang
Microsoft Community Support
--------------------
Get Secure! ¡§C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn
This posting is provided "AS IS" with no warranties, and confers no rights.
Oliver Sturm - 08 Sep 2005 11:16 GMT
>Is it possible to open a misc document from a ToolWindow?
>
>It seems I should be able to use the method
>VsShellUtilities.OpenDocumentWithSpecificEditor, but I don't really have a
>IServiceProvider in the ToolWindow.
Your package is derived from Microsoft.VisualStudio.Shell.Package, I
assume. This class implements IServiceProvider, so you should be able to
pass it in to the OpenDocumentWithSpecificEditor method.
Oliver Sturm

Signature
Expert programming and consulting services available
See http://www.sturmnet.org (try /blog as well)
"Ed Dore [MSFT]" - 09 Sep 2005 21:37 GMT
Hi Shirley,
All toolwindows get an IServiceProvider. When a toolwindow is created, it's
IVsWindowPane.SetSite implementation is called with an IOleServiceProvider
that you can call QueryService on. I suspect you're using the new package
wizard generated stuff though, so it's not really obvious how to do this.
A toolwindow implemented with MPF, is typically derived from a
ToolWindowPane object that has a GetService method on it. So you can call
this method to retrieve any specific type of service you require (provided
it's available).
That all being said, it's unclear what exactly you are attempting to do. If
you are simply looking for a way to open a document FROM your toolwindow,
you can use the DTE automation object's ExecuteCommand() or
ItemOperations.FileOpen().
To retreive the DTE object, you just need to call GetService(typeof(_DTE)).
If you are actually talking about implementing/displaying an editor within
the confines of your own toolwindow, there is no support for that. You can
create and parent the core text editor off of your own toolwindow, but
generally speaking other editors won't take to kindly to being parented on
a toolwindow, unless they've actually specifically been designed to support
that).
Sincerely,
Ed Dore [MSFT]
This post is 'AS IS' with no warranties, and confers no rights.