views:

922

answers:

1

I'm writing a (very) simple Visual Studio addin. Two things that would make it work nicer are:

  1. A context menu.

  2. Knowing the caret position in the current document (so I can inject text at that position).

Any ideas?

+5  A: 

To add a context menu to your addin, you create a CommandBarPopup from:

_applicationObject.CommandBars["Code Window"]

You can view a sample here.

The second part of your question is a little simpler, the current "selection" (or insertion point) is handled by:

(TextSelection)_applicationObject.ActiveDocument.Selection

"_applicationObject" is an instance the DTE Application object created by the add-in project wizard.

Jim H.
i dont the sample works for Visual Studio 2008, does it?
Adam