使用Vista Desktop Scheme更改工具栏的背景颜色 [英] Changing Background colour of Toolbar with Vista Desktop Scheme
问题描述
我正在尝试更改工具栏的后组颜色.创建后,我会致电:
I am trying to change the backgroup colour of a Toolbar. After creation I call:
SetClassLong(hWndToolbar,GCL_HBRBACKGROUND,(LPARAM)CreateSolidBrush(RGB(0xff,0,0)));
SetClassLong(hWndToolbar, GCL_HBRBACKGROUND, (LPARAM) CreateSolidBrush(RGB(0xff,0,0)));
在大多数情况下,这会将工具栏的背景更改为红色,但是如果桌面主题是Vista Basic或Vista Aero,则它什么都不做.
In most cases this changes the background of the toolbar to red, BUT if the desktop theme is Vista Basic or Vista Aero it does nothing.
您知道如何在选择Vista Basic/Aero的情况下更改颜色吗?谢谢.
Any idea how to change the colour with Vista Basic/Aero selected? Thanks.
推荐答案
最后找到了答案.在这里列出所有正在搜索的人...
Finally found the answer. Listed here for anyone searching...
需要关闭主题.要使用所有版本的Windows,代码如下:
The Theme needs to be turned off. To work with all versions of Windows here is the code:
void UpdateBackground(HWND hWndToolbar) {
HMODULE hTheme;
hTheme = LoadLibrary("UXTheme.DLL");
if(hTheme){
; void(WINAPI * SetWindowTheme)(HWND,void *,void *);
(FARPROC)SetWindowTheme = GetProcAddress(hTheme,"SetWindowTheme");
if(SetWindowTheme)SetWindowTheme (hWndToolbar,L",L");
FreeLibrary(hTheme);
}
SetClassLong(hWndToolbar,GCL_HBRBACKGROUND,(LPARAM)CreateSolidBrush(RGB(0, 0,0xFF))));
}
void UpdateBackground(HWND hWndToolbar) {
HMODULE hTheme;
hTheme = LoadLibrary("UXTheme.DLL");
if (hTheme) {
void(WINAPI *SetWindowTheme)(HWND,void *,void *);
(FARPROC) SetWindowTheme = GetProcAddress(hTheme,"SetWindowTheme");
if (SetWindowTheme) SetWindowTheme(hWndToolbar,L"",L"");
FreeLibrary(hTheme);
}
SetClassLong(hWndToolbar, GCL_HBRBACKGROUND, (LPARAM) CreateSolidBrush(RGB(0,0,0xFF)));
}
这篇关于使用Vista Desktop Scheme更改工具栏的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!