Visual Studio 2010 - 半透明浮动窗口
是否可以在 Visual Studio 2010 中使浮动窗口半透明?我希望能够浮动编辑器窗口并降低其 Alpha 级别。可以使用修改股票编辑器窗口的扩展来创建此功能吗?
如果不是扩展,是否有合适的第三方应用程序能够修改 Visual Studio 2010 中特定子窗口的属性?
Is it possible to make floating windows in Visual Studio 2010 semi-transparent? I would like to be able to float an editor window and reduce the alpha level on it. Could this functionality be created with an extension that modifies the stock editor window?
If not an extension, are there decent third party applications which would be capable of modifying the properties of specific child windows in Visual Studio 2010?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
主要问题是,它取决于工具窗口,因为 Visual Studio 对于工具窗口的实际呈现方式没有太多要求。
如果工具窗口有 HNWD 可供使用,您可以使用 SetLayeredWindowAttributes 函数。如果工具窗口是WPF,则可以使用其他技巧。
现在,问题是要掌握一些有用的东西...只需在 Visual Studio 2010 上启动 SPY++,您就会发现周围没有太多可见的 HWND。有些包使用非托管代码,有些包使用.NET + Winforms,最近的包越来越多地使用.NET + WPF。
UISpy(另一个间谍工具,但基于 UI 自动化)可以看到所有工具窗口,但不显示任何本机 WIndow 句柄(UI 自动化可以读取的标准属性之一) )这可不是什么好消息。
Visual Studio 使用 IVsWindowPane 接口,特别是 CreatePaneWindow 方法来创建主机窗口,但没有任何官方方法可以获取任何 HWND 句柄来使用。
唔!如果您有想要调整的特定工具窗口,我们可以进行更深入的研究,但我认为编写 100% 通用工具很困难。
编辑:我进行了更多搜索。下面是枚举当前 Visual Studio 实例的所有窗口框架(停靠或浮动)的代码:
这将给出 WindowFrame 实例的列表。 WindowFrame 没有文档记录,但它是公共的(位于 Microsoft.VisualStudio.Platform.WindowManagement.dll 中),因此您可以使用它。每个 WindowFrame 实例都有一个 FrameView 属性,该属性具有一个 Content 属性。根据我的发现,此 Content 属性在大多数情况下是 WPF 的 Panel 元素。该面板下方的层次结构将取决于窗口的实际实现方式。
如果它是非托管或 Winform(例如,.SQL 编辑器),则面板的子集合中将有一个 HwndHost。我尝试使用它(使用 SetLayeredWindowAttributes< /a>),但它似乎不起作用...
如果它是一个 WPF(例如,全新的 C#/VB 编辑器),将会有一个巨大的 WPF 层次结构,最终会下降到 IWfpTextView 实现。您可以在此层次结构中更改许多内容,有些内容可以工作(例如背景属性),但是...关于透明度,我认为这是不可能的,因为根窗口不允许这样做(它有 AllowTransparency 设置为 false,并且不能一旦显示就改变)。例如,设置 Opacity = 0.5 是可行的,但由于没有透明度,效果只是使窗口变暗......
The main the problem is, it depends on the tool window, because Visual Studio does not mandate much about how the tool window is actually rendered.
If the tool window has an HNWD to play with, you can set transparency using the SetLayeredWindowAttributes function. If the tool window is WPF, you can use other tricks.
Now, the problem is to get a hold on something useful... Just launch SPY++ over Visual Studio 2010 and you will see there are not many visible HWND around. Some package use unmanaged code, some packages use .NET + Winforms, and more and more, recent packages use .NET + WPF.
UISpy (another spy tool, but based on UI Automation) sees all tool windows but it does not show any Native WIndow Handle (one of the standard property that UI automation can read) which is not good news.
Visual Studio uses the IVsWindowPane interface and specifically the CreatePaneWindow method to create the host window, but there is nothing official to get any HWND handle back to play with.
Hmm! If you have a specific tool window you want to tweak, we can have a deeper look, but I think it's difficult to write a 100% generic tool.
EDIT: I have searched further more. Here is a code that enumerates all windows frames (docked or floating) of the current Visual Studio instance:
This will give a list of WindowFrame instances. WindowFrame is not documented but it's public (located in Microsoft.VisualStudio.Platform.WindowManagement.dll) , so you can play with it. Each WindowFrame instance has a FrameView property that has a Content property. This Content property is, most of the time from my findings, a WPF's Panel element. The hierarchy below that panel will then be dependent on how the window is actually implemented.
If it's an unmanaged or Winforms (example, the .SQL editor), there will be an HwndHost in the panel's children collection. I have tried to play with it (using SetLayeredWindowAttributes), but it does not seem to work...
If it's a WPF (example, the brand new C#/VB editor), there will be a huge WPF hiearchy, that will eventually go down to an IWfpTextView implementation. You can change many things along in this hierarchy, and some will work (such as the Background property), but... concerning the transparency, I don't think it's possible because the root window does not allow it (it has AllowTransparency set to false, and it can't be changed once it's displayed). Setting Opacity = 0.5 for example works, but since there is no transparency, the effect is just dimmed windows...
您是否检查过 Visual Studio 颜色主题编辑器 ?如果它不能满足您的需要,也许您可以向作者请求该功能。
Have you checked out Visual Studio Color Theme Editor? If it doesn't do what you need maybe you can request the feature from the author.