Toolbar color

This is a discussion on Toolbar color within the Windows Programming forums, part of the Platform Specific Boards category; In an application im creating my toolbar is white for some reason, I copied and pasted to code from another ...

  1. #1
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Posts
    483

    Toolbar color

    In an application im creating my toolbar is white for some reason, I copied and pasted to code from another application, and there the color was beige? (the usual color that a toolbar should be).

    What caused my toolbar to change color? Also how can I change the toolbar's color to any color I want?

    here is my code for creating the toolbar:
    Code:
    			toolbar = CreateWindowEx(0, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT,
    				0, 0, 0, 0,	hwnd, (HMENU)MAIN_TOOLBAR, HInstance, NULL);
    			
    			SendMessage(toolbar, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
    			SendMessage(toolbar, TB_SETBITMAPSIZE, NULL, MAKELONG(20, 24));
    	
    			TBBUTTON tbb[6];
    			TBADDBITMAP tbab;
    			HBITMAP hbitmap = LoadBitmap(HInstance, MAKEINTRESOURCE(IDB_STANDARD));
    			tbab.hInst = NULL;
    			tbab.nID = (UINT_PTR)hbitmap;
    			
    			SendMessage(toolbar, TB_ADDBITMAP, 6, (LPARAM)&tbab);
    			
    			ZeroMemory(tbb, sizeof(tbb));
    
    			tbb[0].iBitmap = 0;
    			tbb[0].fsState = TBSTATE_ENABLED;
    			tbb[0].fsStyle = TBSTYLE_BUTTON;
    			tbb[0].idCommand = ID_NEW;
    			
    			tbb[1].iBitmap = 1;
    			tbb[1].fsState = TBSTATE_ENABLED;
    			tbb[1].fsStyle = TBSTYLE_BUTTON;
    			tbb[1].idCommand = ID_OPEN;
    
    			tbb[2].iBitmap = 2;
    			tbb[2].fsState = TBSTATE_ENABLED;
    			tbb[2].fsStyle = TBSTYLE_BUTTON;
    			tbb[2].idCommand = ID_SAVEAS;
    		    
    			tbb[3].iBitmap = 3;
    			tbb[3].fsState = TBSTATE_ENABLED;
    			tbb[3].fsStyle = TBSTYLE_BUTTON;
    			tbb[3].idCommand = ID_ALIGN_LEFT;
    
    			tbb[4].iBitmap = 4;
    			tbb[4].fsState = TBSTATE_ENABLED;
    			tbb[4].fsStyle = TBSTYLE_BUTTON;
    			tbb[4].idCommand = ID_ALIGN_CENTER;
    
    			tbb[5].iBitmap = 5;
    			tbb[5].fsState = TBSTATE_ENABLED;
    			tbb[5].fsStyle = TBSTYLE_BUTTON;
    			tbb[5].idCommand = ID_ALIGN_RIGHT;
                
    			SendMessage(toolbar, TB_ADDBUTTONS, sizeof(tbb)/sizeof(TBBUTTON), (LPARAM)&tbb);
    My Website
    010000110010101100101011
    Add Color To Your Code!

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Toolbars with the TBSTYLE_FLAT style are essentially transparent so will possess the same 'background' colour as whatever is underneath. So, if the parent of the toolbar, or some other window immediately below the toolbar, is white, you'll need to change the background colour beneath the toolbar to whatever colour you want (if you want default behaviour then use GetSysColor(COLOR_BTNFACE) for that colour). Alternatively, just lose the TBSTYLE_FLAT toolbar style.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Posts
    483
    Works perfectly,

    Thank you.
    My Website
    010000110010101100101011
    Add Color To Your Code!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Critique my lighting model.
    By psychopath in forum Game Programming
    Replies: 4
    Last Post: 08-12-2006, 06:23 PM
  2. egavga.bgi problem
    By sunil21 in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 09-22-2003, 05:06 PM
  3. My opinion on skin color
    By Leeman_s in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 07-11-2003, 12:12 PM
  4. [WinAPI] Developing a color customizable program
    By Templario in forum Windows Programming
    Replies: 6
    Last Post: 02-04-2003, 05:12 PM
  5. Just one Question?
    By Irish-Slasher in forum C++ Programming
    Replies: 6
    Last Post: 02-12-2002, 09:19 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21