locked
Can't get IVsTextLinesEvents for HTML/ASPX documents RRS feed

  • Question

  • Using C++, I'm listening for IVsTextLinesEvents events, and it works just fine for most file types (C++/C#/VB).  However for HTML and ASPX files, I can't find a connection point, so I can't advise.  A simplified example (with no error handling) is below.  Is it possible to get these events for these file types?  Thanks!

    void TextEventsListener::Connect(VSCOOKIE docCookie)
    {
    CComPtr<IVsRunningDocumentTable> rdt = GetIVsRunningDocumentTable();

    CComPtr<IUnknown> buffer;
    rdt->GetDocumentInfo(docCookie, NULL, NULL, NULL, NULL, NULL, NULL, &buffer);

    CComQIPtr<IConnectionPointContainer> ptCon(buffer);
    CComPtr<IConnectionPoint> pt;

    // This line fails for HTML and ASPX files
    ptCon->FindConnectionPoint(IID_IVsTextLinesEvents, &pt);

    pt->Advise((IVsTextLinesEvents *)this, &mLinesEventCookie);
    }


    Friday, September 14, 2012 6:14 AM

Answers

  • The HTML/ASPX stuff implement IVsTextBufferProvider, you need to cast the buffer object returned from the RDT to that, ask it for the real buffer and then go down the IConnectionPointContianer route.

    Ryan

    Monday, September 17, 2012 9:50 PM

All replies

  • Hi Mark,

    Can the function of Connect be called?

    Can we get the RDT of HTML and ASPX files well?

    We can use IsDocDataReloadable(Int32%)  to determine it.

    If we set some breakpoints and debug it, can we found what causes your issue? 

    Best regards,


    Ego [MSFT]
    MSDN Community Support | Feedback to us

    Monday, September 17, 2012 5:42 AM
  • The HTML/ASPX stuff implement IVsTextBufferProvider, you need to cast the buffer object returned from the RDT to that, ask it for the real buffer and then go down the IConnectionPointContianer route.

    Ryan

    Monday, September 17, 2012 9:50 PM
  • Thanks, Ryan.  That did it!

    Tuesday, September 18, 2012 3:36 AM