堡主大名花花

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 :: 管理 ::

在vspackage中使用outputwindow

方法1:

            //output window
            OutputWindow ow = (this.dte as DTE2).ToolWindows.OutputWindow;
            OutputWindowPane owP;
            // Add a new pane to the Output window.
            owP = ow.OutputWindowPanes.Add("A New Pane");
            // Add a line of text to the new pane.
            owP.OutputString("hello my output window");  
 

 

方法2:

           IVsOutputWindow outputWindow = GetService(typeof(SVsOutputWindow)) as IVsOutputWindow;
           // Guid guildGeneral = Microsoft.VisualStudio.VSConstants.OutputWindowPaneGuid.GeneralPane_guid;
            Guid guildGeneral = VSConstants.OutputWindowPaneGuid.BuildOutputPane_guid;
           
            int hr = output.CreatePane(guildGeneral, "Build1", 1, 0);
            hr = output.CreatePane(guildGeneral, "Build2", 1, 0);
            hr = output.CreatePane(guildGeneral, "Build3", 1, 0);
            hr = output.CreatePane(guildGeneral, "Build4", 1, 0);
           
            IVsOutputWindowPane pane;
            int hr = outputWindow.GetPane(ref guildGeneral, out pane);
            pane.Activate();
            pane.OutputString("Hello world");
            Guid customGuid = new Guid("0F44E2D1-F5FA-4d2d-AB30-22BE8ECD9789");
            string customTitle = "Custom Window Title";
            outputWindow.CreatePane(ref customGuid, customTitle, 1, 1);
            IVsOutputWindowPane customPane;
            outputWindow.GetPane(ref customGuid, out customPane);
            customPane.OutputString("Hello, Custom World!");
            customPane.Activate(); // Brings this pane into view

 

 

 

 

dte获取

var dte = this.ServiceProvider.GetServiceAsync(typeof(DTE)).ConfigureAwait(false).GetAwaiter().GetResult() as DTE; 

 

posted on 2019-06-10 10:51  堡主大名花花  阅读(92)  评论(0)    收藏  举报