title: How to enable modern look and feel of tool bar for Win32 Application?
body: <p>Recently I started learning GUI programming based on Win32 API. When I add tool bar control (from <strong>comctl32.lib</strong>) to my simple application I find it looks flat while the menu bar has more "Windows 7 friendly" 3D look and feel (white glow at the top and vertical gray gradient from top to bottom). The difference makes it look wired.</p>
  
  <p><img src="https://i.stack.imgur.com/Qrhse.png" alt="Default ToolBar style"></p>
  
  <p>However, I find many other applications have consistent look and feel for both menu bar and tool bar. Eg. <a href="http://notepad-plus-plus.org/" rel="nofollow noreferrer">Notepad++</a> and <a href="http://www.flos-freeware.ch/notepad2.html" rel="nofollow noreferrer">Notepad 2</a>.</p>
  
  <p><img src="https://i.stack.imgur.com/OL6La.png" alt="Notepad++">
  <img src="https://i.stack.imgur.com/LVX20.png" alt="Notepad 2"></p>
  
  <p>I've read some official documents and tried the solution, such as <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/hh270423(v=vs.85).aspx" rel="nofollow noreferrer">Visual Styles Overview</a>, <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb773175(v=vs.85).aspx" rel="nofollow noreferrer">Enabling Visual Styles</a>, however, it only enables the flat button style (compared to the old Win98 solid button style). It made no difference with the style I got in the first picture.</p>
  
  <p>I tried to read Notepad++'s source code. Found <a href="http://svn.tuxfamily.org/viewvc.cgi/notepadplus_repository/trunk/PowerEditor/src/WinControls/ToolBar/ToolBar.cpp?revision=896&amp;view=markup" rel="nofollow noreferrer">ToolBar.cpp</a> and made some changes to my code accordingly, but nothing changed. I think I was lost in the code base.</p>
  
  <p>Here is my code of calling <code>InitCommonControlsEx</code> and creation of the ToolBar.</p>
  
  
  
  <pre class="lang-c prettyprint-override"><code>// in WinMain
  INITCOMMONCONTROLSEX icce;
  icce.dwSize = sizeof(INITCOMMONCONTROLSEX);
  icce.dwICC = ICC_BAR_CLASSES | ICC_COOL_CLASSES | ICC_USEREX_CLASSES;
  InitCommonControlsEx(&amp;icce);
  
  // called in WM_CREATE handler, hwnd is the handle of the main window
  VOID BuildToolBar(HWND hwnd)
  {
      HWND hTool;
      TBBUTTON tbb[3];
      TBADDBITMAP tbab;
  
      hTool = CreateWindowEx(0, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | TBSTYLE_TOOLTIPS |TBSTYLE_FLAT | CCS_TOP | BTNS_AUTOSIZE, 0, 0, 0, 0, hwnd, (HMENU)IDC_MAIN_TOOL, GetModuleHandle(NULL), NULL);
      SendMessage(hTool, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
      SendMessage(hTool, TB_SETEXTENDEDSTYLE, 0, (LPARAM)TBSTYLE_EX_HIDECLIPPEDBUTTONS);
  
      tbab.hInst = HINST_COMMCTRL;
      tbab.nID = IDB_STD_SMALL_COLOR;
      SendMessage(hTool, TB_ADDBITMAP, 0, (LPARAM)&amp;tbab);
  
      ZeroMemory(tbb, sizeof(tbb));
      tbb[0].iBitmap = STD_FILENEW;
      tbb[0].fsState = TBSTATE_ENABLED;
      tbb[0].fsStyle = TBSTYLE_BUTTON;
      tbb[0].idCommand = ID_FILE_NEW;
  
      tbb[1].iBitmap = STD_FILEOPEN;
      tbb[1].fsState = TBSTATE_ENABLED;
      tbb[1].fsStyle = TBSTYLE_BUTTON;
      tbb[1].idCommand = ID_FILE_OPEN;
  
      tbb[2].iBitmap = STD_FILESAVE;
      tbb[2].fsState = TBSTATE_ENABLED;
      tbb[2].fsStyle = TBSTYLE_BUTTON;
      tbb[2].idCommand = ID_FILE_SAVEAS;
  
      SendMessage(hTool, TB_SETBUTTONSIZE, (WPARAM)0, (LPARAM)MAKELONG(16, 16));
      SendMessage(hTool, TB_ADDBUTTONS, sizeof(tbb) / sizeof(TBBUTTON), (LPARAM)&amp;tbb);
      SendMessage(hTool, TB_AUTOSIZE, 0, 0);
  }
  </code></pre>
  
  <p>So, <strong>The Question Is:</strong> Despite the bitmaps of the buttons, how can I get 3D look and feel for the tool bar, just like the Notepad++/Notepad2 example?</p>
  
  <p>Thanks in advance.</p>