Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Don Halloran

SQL Server, SSIS, SSAS and maybe even SSRS rants and raves (and, on occasion, useful code or designs).

SSMS addin (and wrapper)

So I mentioned I'd been working on an SSMS addin. What I didn't mention was that I've also been working on a wrapper to make addin creation easier. I actually first looked at this nearly 12 months ago, but so much reading and trial and error was required that I never found time to really flesh it out.

Now, though, I'm on holidays for the first time since I began. And so now I finally have some progress to report.

The wrapper is dubbed SSMSW08. Here are some basic examples on its use. After creating the standard extensibility project type, you instantiate the wrapper in the OnConnection method, thusly:
[pref] _SSMS = new SSMSW08.SSMS(addInInst); [endpref]
From there you can start playing with the features of the visual studio environment much more easily. For instance, want to create a flyout menu for your addin on the tools menu, with some command? That looks like so:
[pref] _SSMS.command_manager.create_popup_menu("Tools", "SSMSDeploy", "SSMSDeploy", 0); _SSMS.command_manager.create_popup_menu_command("SSMSDeploy", "my_command", "my_command", "my_command", 0, null, null); [endpref] The zero arguments are for the position on the menus. Zero means "put at the end".

The null arguments are delegates to work with the IDTCommandTarget interface, dealing with QueryStatus and Exec, so that your toolbar commands actually show up and do something . Passing nulls tells the wrapper to use its own internal default handlers. The second one is for the Exec handler, so the command won't actually do anything if created like this, but my actual addin is still a work in progress.

Since QueryStatus and Exec have to be implemented in the actual addin class, you have to offload responsibility to the wrapper there. But I made that easy too: [pref] public void QueryStatus(string commandName, vsCommandStatusTextWanted neededText, ref vsCommandStatus status, ref object commandText) { _SSMS.command_manager.QueryStatus(commandName, neededText, ref status, ref commandText); } public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled) { _SSMS.command_manager.Exec(commandName, executeOption, ref varIn, ref varOut, ref handled); } [endpref]
These functions will in turn call either your delegates or the default handlers.

Want to create a window in the enviroment to host a user control? Easy, here's an example from my addin (and a hint at to what my addin will be!):
[pref] object window_obj = null; Window deployment_control = _SSMS.window_manager.create_tool_window( System.Reflection.Assembly.GetExecutingAssembly().Location, "SSMSDeploy.DeploymentControl", // the name of the user control class "Deployment List", // caption "{21e5ac34-1e26-4399-81d1-5cfe33670d48}", // arbitrary! ref window_obj ); [endpref]
Some day soon I will make the full wrapper available (still working on the event manager), and the addin should come a few days after that!

Comments

Posted by Anonymous on 5 January 2011

Pingback from  Dew Drop – January 5, 2011 | Alvin Ashcraft's Morning Dew

Leave a Comment

Please register or log in to leave a comment.