visual-studio 在 Visual Studio 中更改解决方案资源管理器的背景颜色
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/189043/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Change background color of Solution Explorer in Visual Studio
提问by zadam
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?
有没有办法使用主题更改 Visual Studio 中解决方案资源管理器的背景颜色?- 或者任何其他方式?
I can change it by changing windows-wide color settings, but obviously that affects too much.
我可以通过更改 Windows 范围的颜色设置来更改它,但显然这影响太大。
采纳答案by Ivan G.
Just created VS extension for that in under an hour, search extension manager for "SExColor". Enjoy ;)
刚刚在不到一个小时的时间内为此创建了 VS 扩展,搜索“SExColor”的扩展管理器。享受 ;)
回答by user1195662
@aloneguid ...should have seen this long time ago.. thank you sir !
@aloneguid ……应该很久以前就看过了……谢谢先生!
@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
@ver(关于与 2008 年的解决方案相比;) - 一种 B52 类型的方法,对 devenv.exe 中的任何 SysTreeView32 进行地毯式轰炸。所需颜色的可能额外参数,否则 RGB(220,220,220) - 最适合我
#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;
}
回答by sharkin
Not by any means of configuration from Visual Studio itself.
不是通过 Visual Studio 本身的任何配置方式。
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.
但是,您可能可以从 Win32 API 中“破解”窗口对象(查找“窗口枚举”)。一旦你有了窗口句柄,你就可以设置你想要的所有特征。
Regards
问候
/Robert
/罗伯特
回答by CleverPatrick
Even changing the standard Windows background color does not work for the Solution Explorer. This Visual Studio bug reportmentions the issue. Microsoft has marked this as "Closed -- Won't Fix."
即使更改标准的 Windows 背景颜色也不适用于解决方案资源管理器。这个 Visual Studio错误报告提到了这个问题。微软已将此标记为“已关闭——无法修复”。
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 Toolsprovides 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.)
一种可能的解决方案是根本不使用解决方案资源管理器。在生产力电动工具提供了一个解决方案资源管理器更换称为“导航解决方案。” 它目前也被硬编码为白色。但我认为让该工具的开发人员添加对修改颜色的支持可能比让 Microsoft 在 Visual Studio 中做这件事更有可能。(即使微软创建了 PPT。)
回答by Jacek
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)
你可以使用其他扩展,你有很大的可能性让你的 Visual Studio 看起来更漂亮;)(但我不确定你是否可以改变解决方案资源管理器的背景)
http://visualstudiogallery.msdn.microsoft.com/20cd93a2-c435-4d00-a797-499f16402378
http://visualstudiogallery.msdn.microsoft.com/20cd93a2-c435-4d00-a797-499f16402378

