0

Thanks to this answer, I can change background & foreground colors of my Solution explorer and Server explorer of Visual studio 2010 with following C++ console application. But a problem is that this code does not change the colors of Class View.

enter image description here

According to Spy++ in VS, the Class View mainly consists of three Window classes, two LiteTreeView32 and a VsSimpleSlider. With VS Debugging, I verified that the program is correctly sending color change messages to the LiteTreeView32 windows in Class View. I am guessing that LiteTreeView32 may not accept those color change messages but I am not sure. Any clue will be appreciated. In addition, any idea how to change colors of Properties window which seems like .NET component?

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

using namespace std;

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

BOOL CALLBACK wenum( HWND hwnd, LPARAM lParam)
{
    const UINT cb = 261;
    static wchar_t    name[] = L"SysTreeView32",//other treeviews including solution explorer
        name2[] = L"LiteTreeView32",//treeview inside of class view
        name3[] = L"WindowsForms10.STATIC.app.0.1fed012_r46_ad1",//hopefully property grid
        name4[] = L"VsSimpleSlider",
        tmp[cb] = {0};
    int res = ::GetClassNameW( hwnd, tmp, 260 );
    if(res  && (
        0 == _wcsicmp( name, tmp ) 
        ||0 == _wcsicmp( name2, tmp ) 
        ||0 == _wcsicmp( name3, tmp )
        ||0 == _wcsicmp( name4, tmp )
        ))
    {
        ::SendMessageW( hwnd, TVM_SETBKCOLOR, 0, (LPARAM)clr );
        ::SendMessageW( hwnd, TVM_SETTEXTCOLOR, 0, (LPARAM)clr2 );
        wcout << tmp << endl;
    }
    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);
    int dummy;
    cin >> dummy; 
    return 0;
}
Community
  • 1
  • 1
Tae-Sung Shin
  • 20,215
  • 33
  • 138
  • 240
  • A little confused by your question. Is it just about the theme, i.e., http://stackoverflow.com/questions/3361918/dark-theme-for-visual-studio-2010-with-productivity-power-tools – Raja Oct 17 '13 at 08:00
  • @Raja Even with the theme, you cannot make, for example, Solution Explorer dark easily. With the method above, you can do that for some sub-windows with treeview but not for the others. I am talking about them (the others) that can't be dark. – Tae-Sung Shin Oct 17 '13 at 16:21
  • Take a look at this blog..Its been stated that SendMessage works in vs2010 but due to the switch to WPF the Solution Explorer is no longer a win32 control, this means you can’t get a handle to it and use SendMessage like in previous versions.Not all tree views are WPF though, for instance the Server Explorer and Class View both aren’t, and once their background color is updated to white the icons look normal. So unless there’s a way to do the same with the Solution Explorer this all seems rather pointless. http://blog.hackingonhacks.com/2012/09/03/visual-studio-icon-patcher/ – hridya pv Oct 18 '13 at 06:38
  • @hridyapv I read the article with more care and found that it is about VS 2012. I am talking about VS 2010. – Tae-Sung Shin Oct 18 '13 at 14:39

0 Answers0