Click here to Skip to main content
15,894,291 members
Please Sign up or sign in to vote.
0.00/5 (No votes)

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)));

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.

Any idea how to change the colour with Vista Basic/Aero selected? Thanks.

Posted

1 solution

Finally found the answer. Listed here for anyone searching...

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)));
}

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900