58

Is there any way to change the background color of the Solution Explorer in Visual Studio using a Theme? - or any other way for that matter?

I can change it by changing windows-wide color settings, but obviously that affects too much.

GEOCHET
  • 21,119
  • 15
  • 74
  • 98
zadam
  • 2,416
  • 2
  • 23
  • 32

5 Answers5

35

Just created VS extension for that in under an hour, search extension manager for "SExColor". Enjoy ;)

Ivan G.
  • 5,027
  • 2
  • 37
  • 65
  • trivial, finding solution explorer window which is a treeview control, and sending windows message to change colors :) – Ivan G. Nov 07 '11 at 14:30
  • @aloneguid can I get a VS2008 version somewhere? (Or get the source code for it?) – ver Jan 31 '12 at 11:18
  • 11
    Would you be able to direct us to the source code? Is this on github by any chance? The reason I ask is because I'd like to achieve the same results for the "Server Explorer", "To-do Explorer", "Properties", "Error List", and "Macro Explorer" – Chase Florell Feb 17 '12 at 20:28
  • 1
    Gah! Installed in VS2010 and blanked out my entire solution explorer. Uninstalling – Dr. Andrew Burnett-Thompson May 01 '12 at 15:04
  • 1
    Visual studio would randomly lock up when trying to open new solutions, and the logs said it was while trying to load your package. Everything works again after uninstalling it. – Jamie Penney Jun 06 '12 at 02:22
  • 2
    Have you adapted this for 2012 yet? :) – NickG Aug 23 '12 at 16:32
  • 1
    After installing, go to `Tools | Options | SExColor`. – Roger Dahl Mar 06 '13 at 05:13
  • For 2012, you can use the inbuilt one via: Tools -> Options -> General : Color Theme – Raja Oct 17 '13 at 03:54
  • Could you possibly explain why this is not working after I change the color? I have already restarted visual studio after changing the colors, and it had the correct colors under options, but not on the solution explorer itself. – Sam Williams Jul 29 '16 at 18:40
10

@aloneguid ...should have seen this long time ago.. thank you sir !

@ver (regarding vs 2008 solution for solution;) - a B52 type of approach, carpet bombing on anything that is SysTreeView32 inside a devenv.exe. Possible extra param for desired color, otherwise RGB(220,220,220) - works best for me

#include <windows.h>
#include "psapi.h"
#include "shlwapi.h"
#include "commctrl.h"


COLORREF clr = RGB(220,220,220);

BOOL CALLBACK wenum( HWND hwnd, LPARAM lParam)
{
   const UINT cb = 261;
   static wchar_t    name[] = L"SysTreeView32",
                     tmp[cb] = {0};
   if( ::GetClassNameW( hwnd, tmp, 260 ) && 0 == _wcsicmp( name, tmp ) )
   {
      ::SendMessageW( hwnd, TVM_SETBKCOLOR, 0, (LPARAM)clr );
   }

   return TRUE;
}

BOOL CALLBACK EnumTops(HWND hwnd, LPARAM lParam) 
{
    DWORD             dwThreadId  = 0, 
                     dwProcessId = 0;
    HINSTANCE         hInstance;
   static wchar_t derVS[]     = L"devenv.exe";
   wchar_t  name[_MAX_PATH]   = {0},
            *exe              = 0;

    HANDLE hProcess;
   if (!hwnd)  return TRUE;     // Not a window
   if (!::IsWindowVisible(hwnd)) return TRUE;       // Not visible

   if (!SendMessage(hwnd, WM_GETTEXT, sizeof(name), (LPARAM)name))
      return TRUE;      // No window title
   dwThreadId = GetWindowThreadProcessId(hwnd, &dwProcessId);
   hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwProcessId);
   if( !GetModuleFileNameEx(hProcess, 0, name, sizeof(name))) goto exit;

   exe = ::PathFindFileNameW( name );
   if( (void*)exe == (void*)name ) goto exit; // mhm? maybe not exit?

   if( _wcsicmp( derVS, exe ) ) goto exit;

   EnumChildWindows( hwnd, wenum, (LPARAM)hProcess );

exit:
   CloseHandle(hProcess);
   int res = GetLastError();
   return res;
}

int wmain(int argc, wchar_t * argv[]) 
{
   if( argc >= 2 )
   {
      wchar_t *end = 0;
      long l = wcstol( argv[1], &end, 16 );
      clr = (DWORD)l;
   }
   ::EnumWindows(EnumTops, NULL);
   return 0;
}
user1195662
  • 101
  • 1
  • 2
4

Not by any means of configuration from Visual Studio itself.

You can however probably "hack" the window object from the Win32 API (look up "window enumeration"). Once you have the window handle, you can set all characterstics you want.

Regards

/Robert

sharkin
  • 12,162
  • 24
  • 86
  • 122
4

Even changing the standard Windows background color does not work for the Solution Explorer. This Visual Studio bug report mentions the issue. Microsoft has marked this as "Closed -- Won't Fix."

Which is very irritating! Using a dark theme and having a bright white Solution Explorer hanging on the side of the screen is extremely annoying.

One possible solution is to not use the Solution Explorer at all. The Productivity Power Tools provides a Solution Explorer replacement called the "Solution Navigator." It currently is also hard-coded to white. But I think there is probably a better chance of getting the developers of that tool to add support for modifying colors than of getting Microsoft to do it in Visual Studio. (even though Microsoft created the PPTs.)

CleverPatrick
  • 9,261
  • 5
  • 63
  • 86
3

You could use other extenssion, you have quite big possibilities to do your Visual Studio more good looking ;) (but I'm not sure if there you could change Solution Explorer background)

http://visualstudiogallery.msdn.microsoft.com/20cd93a2-c435-4d00-a797-499f16402378

Jacek
  • 11,661
  • 23
  • 69
  • 123
  • I could not find any setting for the Solution Explorer background or several other views' background color. – Magnus Lindhe May 09 '12 at 12:58
  • 5
    After downloading the VS Theme Editor extension, edit a theme. Click the "Show All Elements" button. The property you want to change is called "Treeview -> Background". – csigrist Feb 15 '13 at 18:06
  • @csigrist I... love... you... SOMUCH! missed that there was such an option. I would recommend putting your mention up; it's the real solution for VS2013(and 12?) and would probably save people a lot of time if they hit this and don't happen to see your comment. leave a comment saying you did it I'll come back and vote you up. :) ♥ wow, finally will be able to make this IDE look like I want. – shelleybutterfly May 06 '14 at 21:22