如何以编程方式将 Visual Studio 外接程序窗口附加到选项卡?

发布于 2024-09-18 09:57:34 字数 819 浏览 4 评论 0原文

我正在创建一个小插件,希望能够让 Visual Studio 中的图形处理变得有趣且轻松。不过,有一个小烦恼,我似乎不知道如何将新创建的窗口附加到选项卡栏。

全部都是 F#,但解决方案应该只是几个函数调用,因此请随意在您的答案中使用 C# 或 VB。

type WindowManager(applicationObject: DTE2, addInInstance: AddIn) = 
    member this.CreateWindow(control: Type, caption) = 
        let windowInterface = applicationObject.Windows :?> Windows2
        let tempObj = ref null
        let assemblyLocation = System.Reflection.Assembly.GetExecutingAssembly().Location
        let className = control.FullName
        let instanceGuid = System.Guid.NewGuid().ToString("B")
        let toolWindow = windowInterface.CreateToolWindow2( addInInstance, assemblyLocation, className, caption, instanceGuid, tempObj)
        toolWindow.Visible <- true

我想我只需要将它链接到 applicationObject 中的某些内容即可。唯一的问题是什么。

I'm creating a small addin in the hopes of making it fun and easy to play with graphics in Visual Studio. There has been one small annoyance though, I can't seem to figure out how to attach my newly created window to the tab bar.

It's all F#, but the solution should be just a couple of function calls so please feel free to use C# or VB in your answer.

type WindowManager(applicationObject: DTE2, addInInstance: AddIn) = 
    member this.CreateWindow(control: Type, caption) = 
        let windowInterface = applicationObject.Windows :?> Windows2
        let tempObj = ref null
        let assemblyLocation = System.Reflection.Assembly.GetExecutingAssembly().Location
        let className = control.FullName
        let instanceGuid = System.Guid.NewGuid().ToString("B")
        let toolWindow = windowInterface.CreateToolWindow2( addInInstance, assemblyLocation, className, caption, instanceGuid, tempObj)
        toolWindow.Visible <- true

I think I just need to link it to something in the applicationObject. The only problem is what.

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

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

发布评论

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

评论(2

蓝眼泪 2024-09-25 09:57:34

我的理解是,控制工具窗口位置的唯一方法是通过 VSPackage 提供它,而不是通过 AddIn 提供(请参阅 http://msdn.microsoft.com/en-us/library/bb166406.aspxhttp://msdn.microsoft.com/en-us/library/bb165452.aspx 了解更多信息)。

我认为这种限制的原因是特定工具窗口的位置是用户可控的;即使您通过 VSPackage 提供工具窗口并通过注册表魔术指定其位置(如上面链接所述),您仍然只能控制工具窗口第一次出现的位置。之后,该位置将始终来自用户移动工具窗口的位置,并且这是非常不可覆盖的。

不过我可能会错过一些新的 VS2010 机制。

My understanding is that the only way to control tool window position is to provide it via a VSPackage, not via AddIn (see http://msdn.microsoft.com/en-us/library/bb166406.aspx and http://msdn.microsoft.com/en-us/library/bb165452.aspx for more information).

I believe that the reason for this limitation is that positions of particular tool windows are user-controllable; even if you provide the tool window via VSPackage and specify its position via the registry magic as described in the above links, you still only control the location of a first appearance of a tool window. After that, the location will always come from wherever the user moved your toolwindow, and this is very deliberately non-overridable.

I might be missing some new VS2010 mechanisms though.

像极了他 2024-09-25 09:57:34

我似乎已经明白了:

toolWindow.Linkable <- false
toolWindow.WindowState <- vsWindowState.vsWindowStateMaximize
toolWindow.Visible <- true

I seem to have figured it out:

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