Click here to Skip to main content
15,886,362 members
Articles
(untagged)

Named Bookmarks Add-In for VS.NET

Rate me:
Please Sign up or sign in to vote.
4.17/5 (5 votes)
25 Apr 20052 min read 41.1K   921   10  
Add-In for Visual Studio .NET that implement concept of Named Bookmarks
VsUserControlHost

Because .NET UserControls are not ActiveX controls, a UserControl cannot be directly hosted on a tool window. This 
project is an ATL ActiveX control that can be hosted on a tool window. It then can create an instance of a UserControl
and parent that control onto the ActiveX control, making it look as if the UserControl is within a tool window frame.

To use this control, first build the project. Then add a reference to the VSUserControlHostLib COM object within the COM tab of the Add References dialog (found by right 
clicking on your Add-in Project). Then, in your Add-in, you would write code such as the following:

object objTemp;
VSUserControlHostLib.IVSUserControlHostCtl objVSUserControlHostCtl;
EnvDTE.Window objWindow = objDTE.Windows.CreateToolWindow(objMyAddin, "VSUserControlHost.VSUserControlHostCtl", "My tool window", "{some random guid}", objVSUserControlHostCtl);


Next, you would call the appropriate code to host your UserControl. The method to do this has two formats. The first looks for an assembly that is in the GAC. 
This is demonstrated with this code, which will use a standard CheckBox as the UserControl:
	objVSUserControlHostCtl.HostUserControl("System.Windows.Forms", "System.Windows.Forms.CheckBox");

The second format is to specify an absolute path to an assembly. This is best when you do not have permissions to write into the GAC or you wish to use a user control within the 
assembly that is calling the code:
	objVSUserControlHostCtl.HostUserControl("C:\path\WindowsControlLibrary1.dll", "WindowsControlLibrary1.UserControl1");
If the user control is within the same assembly that the Add-in is located, you could use code like this to discover the path:
	objVSUserControlHostCtl.HostUserControl(System.Reflection.Assembly.GetExecutingAssembly().CodeBase, "WindowsControlLibrary1.UserControl1");


The second parameter in both method calls is the full name to the class implementing the UserControl.

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Canada Canada
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions