Extending current editor

Hi,
     How can we get interfaces like IVSTextBuffer, IVSTextView for current
active text windows. I want to create a addin which will add text like /*My
comment here*/ but this should be displayed as a hyperlink. When user clicks
on it I should get a call.
I tried going through the documentation and samples. But the samples are for
creating new editor and not for extending the current editor using addin.

TIA,
 Ajey



Answer this question

Extending current editor

  • Preposterous

    the code in the FigEdit sample, (editfact.cpp)

    // Create a text buffer if one is not passed to us
    //
    // If you look in textmgr.idl you will see that the
    // object described by 'coclass VsTextBuffer' has two interfaces.
    //
    // By looking at IVsTextLines you see it inherits from IVsTextBuffer
    // so by getting a pointer to IVsTextLines you can call all the methods
    // described by both interfaces.
    //

    CComPtr<IVsTextLines> srpTextLines;

    if( punkDocDataExisting == NULL )
    {
    // we need to create a text buffer
    // get the ILocalRegistry interface so we can use it to
    // load the text buffer from the shell's local registry.
    //

    CComPtr<ILocalRegistry> srpLocalRegistry;
    hr = _AtlModule.QueryService(
     SID_SLocalRegistry, IID_ILocalRegistry,
     (void **)&srpLocalRegistry);
    IfFailRet(hr);

    // create buffer (does CoCreateInstance if not in shell's registry)
    hr = srpLocalRegistry->CreateInstance(
     CLSID_VsTextBuffer, NULL, IID_IVsTextLines,
     CLSCTX_INPROC_SERVER,
     (void **)&srpTextLines );

    IfFailRet(hr);

    should get you the interface you want.

    doc section

    Calling into the Environment SDK from Automation

    will help you access those interfaces from an add-in.



  • Extending current editor