Visual Studio 2010 - Semi-Transparent Floating Windows
Asked Answered
D

2

7

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?

Doubly answered 15/10, 2010 at 19:0 Comment(0)
O
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:

// WindowFrame needs Microsoft.VisualStudio.Platform.WindowManagement.dll
public static IEnumerable<WindowFrame> EnumWindowFrames(Microsoft.VisualStudio.OLE.Interop.IServiceProvider sp, __WindowFrameTypeFlags frameTypes)
{
    if (sp == null)
        throw new ArgumentNullException("sp");

    ServiceProvider serviceProvider = new ServiceProvider(sp);
    IVsUIShell4 shell = (IVsUIShell4)serviceProvider.GetService(typeof(SVsUIShell)); // VS 2010 only

    IEnumWindowFrames framesEnum;
    IVsWindowFrame[] frames = new IVsWindowFrame[1];
    uint numFrames;
    shell.GetWindowEnum((uint)frameTypes, out framesEnum);
    if (framesEnum == null)
        yield break;

    while ((framesEnum.Next(1, frames, out numFrames) == VSConstants.S_OK) && (numFrames == 1))
    {
        WindowFrame frame = frames[0] as WindowFrame;
        if (frame != null)
            yield return frame;
    }
}

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...

Orcinol answered 7/2, 2011 at 9:5 Comment(5)
As the questions says, the concern is about document (editor) windows. This is also the reason why I have started a bounty on it, as solving this would probably allow me to solve my concern in #4880686Odysseus
I have downloaded UIA Verify and used it to inspect the floating document window properties. To my surprise the tool shows the WindowPattern.Current.IsTopmost as false. As for transparency, I did not find anything related to it. I have done some MFC development in past, but no WPF and I do not know what to look for.Odysseus
@Odysseus - I don't think the transparency thing is possible (see my edit). However, some things are possible, like for example automate the positioning of frames.Orcinol
Thanks .I am awarding the bounty, as I think this should be enough to get started. I will post any further progress either here, or in the linked topic.Odysseus
One more question: the code you have posted, this is intended to be executed where or how? Inside of Visual Studio, or as a standalone utility ...?Odysseus
D
0

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.

Declared answered 15/10, 2010 at 19:9 Comment(1)
I have used this extension and it doesn't seem to offer anything resembling transparency from what I can tell.Doubly

© 2022 - 2024 — McMap. All rights reserved.