代码之家  ›  专栏  ›  技术社区  ›  Jeremy Bell

如何获取特定输出窗格的ivstextview?

  •  4
  • Jeremy Bell  · 技术社区  · 15 年前

    我有一个visual studio集成包,它跟踪调试窗口的输出。我可以得到输出窗口的ivstextview,如下所示:

    IVsTextView view = GetService(typeof(SVsOutputWindow)) as IVsTextView;
    // grab text from the view and process it
    

    但是,如果“调试”面板以外的其他面板当前处于活动状态,则此ivstextview将具有该面板中的文本,而不是“调试”面板中的文本。

    在获取输出窗口的ivstextview之前,是否可以在不调用outputWindowPanel.activate()的情况下获取特定输出窗口面板的ivstextview?

    1 回复  |  直到 15 年前
        1
  •  2
  •   Oleg Tkachenko    15 年前

    当然,这是可能的。您只需选择要读取的输出窗口窗格:

    IVsOutputWindow outWindow = GetService(typeof(SVsOutputWindow)) as IVsOutputWindow;
    // Give me the Debug pane
    Guid debugPaneGuid = VSConstants.GUID_OutWindowDebugPane;
    IVsOutputWindowPane pane;
    outWindow.GetPane(ref debugPaneGuid, out pane);
    // Get text view and process it
    IVsTextView view = pane as IVsTextView;