How do I get CreateToolbarEx() to take TBSTYLE_FLAT in order to make my toolbar a coolbar without it behaving as if I also specified TBSTYLE_TRANSPARENT?

How do I get CreateToolbarEx() to take TBSTYLE_FLAT in order to make my toolbar a coolbar without it behaving as if I also specified TBSTYLE_TRANSPARENT?

My problem is that when I add TBSTYLE_FLAT to my toolbar (that was working fine beforehand)...

      hWndToolbar = CreateToolbarEx(
            hwndParent,             // parent
            //WS_CHILD | WS_BORDER | WS_VISIBLE | TBSTYLE_TOOLTIPS,
            WS_CHILD | WS_BORDER | WS_VISIBLE | TBSTYLE_TOOLTIPS | TBSTYLE_FLAT,
            ID_TOOLBAR,             // toolbar id
            //DB increased next line to add buttons
            //24,                     // number of bitmaps
            26,                     // number of bitmaps (i.e. number of non-separator buttons)
            hInst,                              // mod instance
            IDB_TOOLBAR,                  // resource ID for bitmap
            (LPCTBBUTTON)&tbButtons,// address of buttons
            //DB adjusted number in next line to accomodate above adjustments
            //32,                     // number of buttons (including separators)
            34,                     // number of buttons (including separators)
            16,16,                  // width & height of buttons in pixels
            16,16,                  // width & height of bitmaps in pixels
            sizeof(TBBUTTON));      // structure size

... the resulting coolbar has a white/transparent background with hovering not working properly. I want a grey background such as appears in the background of Office 2003.

I read on the Web that there is a bug where TBSTYLE_FLAT wrongly invokes TBSTYLE_TRANSPARENT as well automatically, and a solution is to unload TBSTYLE_TRANSPARENT afterward... but I don't know how to do that.

davidbermancomAsked:
Who is Participating?
 
Dariusz DziaraProgrammerCommented:
I found the following solution in Internet:

http://www.powerbasic.com/support/forums/Forum4/HTML/003071.html

1. Do not use TBSTYLE_FLAT in CreateToolbarEx()

2. Set it (TBSTYLE_FLAT) after CreateToolbarEx()

 ::SetWindowLong(hWndToolbar, GWL_STYLE, ::GetWindowLong(hWndToolbar, GWL_STYLE) | TBSTYLE_FLAT);
0
 
Jase-CoderCommented:
set the constant _WIN32_IE to 0x0600

#define _WIN32_IE 0x0600
#include <commctrl.h>

use the above if you have

"The application is compatible with Comctl32.dll version 6.0 and later, and Shell32.dll and Shlwapi.dll version 6.0 and later. The application cannot implement features that were added after version 6.0 of Comctl32.dll, or version 6.0 of Shell32.dll and Shlwapi.dll." - msdn

or

#define _WIN32_IE 0x0501
#include <commctrl.h>

use this if:

"The application is compatible with Comctl32.dll version 5.81 and later, and Shell32.dll and Shlwapi.dll version 5.0 and later. The application cannot implement features that were added after version 5.81 of Comctl32.dll, or version 5.0 of Shell32.dll and Shlwapi.dll." - msdn

you can test versions of dlls by using:

if(GetDllVersion(TEXT("comctl32.dll")) >= PACKVERSION(5,81))
{

}

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.