如何从加载项显示输出窗口?

发布于 2024-09-27 11:49:20 字数 126 浏览 5 评论 0原文

我目前有一个 Visual Studio 插件,并创建了一个新的输出窗口窗格,我可以在其中成功写入文本。但是,当输出窗口未打开或最小化时,当我在窗格上调用 Activate() 方法时,它不会打开(弹出)。我有什么想法可以实现这一目标吗?

I currently have a visual studio add-in and have created a new output window pane which I can write text to successfully. However, when the output window is not open or it is minimised then it doesn't open (popup) when I call the Activate() method on the pane. Any ideas how I can achieve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

彩虹直至黑白 2024-10-04 11:49:20

如果您使用外接程序向导创建了外接程序,您应该具有如下所示的 Exec() 方法。我添加了两行,使输出窗口打开并变得可见,无论它最初是关闭的还是最小化的。我在VS2008和VS2010中对此进行了测试。

public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled)
{
    handled = false;
    if(executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault)
    {
        if(commandName == "AddinTest.Connect.AddinTest")
        {
            // Find the output window.
            Window outputWindow = _applicationObject.Windows.Item(Constants.vsWindowKindOutput);
            // Show the window. (You might want to make sure outputWindow is not null here...)
            outputWindow.Visible = true;

            handled = true;
            return;
        }
    }
} 

If you created your Add-in using the Add-in wizard you should have an Exec() method like below. I have added two lines that cause the Output window to open and become visible regardless whether it was originally closed or minimized. I tested this in VS2008 and VS2010.

public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled)
{
    handled = false;
    if(executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault)
    {
        if(commandName == "AddinTest.Connect.AddinTest")
        {
            // Find the output window.
            Window outputWindow = _applicationObject.Windows.Item(Constants.vsWindowKindOutput);
            // Show the window. (You might want to make sure outputWindow is not null here...)
            outputWindow.Visible = true;

            handled = true;
            return;
        }
    }
} 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文