Click here to Skip to main content
Licence CPOL
First Posted 27 Jan 2003
Views 153,997
Downloads 6,476
Bookmarked 79 times

Very simple true color toolbar (It's true!)

By DCUtility | 27 Jan 2003
This is TrueColor Toolbar class
2 votes, 5.9%
1

2

3
8 votes, 23.5%
4
24 votes, 70.6%
5
4.75/5 - 34 votes
2 removed
μ 4.56, σa 1.74 [?]

Sample Image - CTrueColorToolBar_Update.jpg

Introduction

CTrueColorToolBar is a real true color toolbar. Implementation of the class is very very easy. The particularity of this toolbar is the auto detection of the mask color with the DIB section of the first pixel of bitmap toolbar.

Steps to use

  1. Create dummy 16 color toolbar in VC with the number of buttons and final size you need.
  2. In your favorite painter, make 3 other true color toolbar bitmaps for state buttons (Normal, Hot, Disabled) based on the first one.
  3. Import your new true color toolbars in VC.
  4. Create new CTrueColorToolBar toolbar with the sample implementation of normal toolbar.
  5. Call LoadTrueColorToolBar function with your 3 true color toolbar bitmaps and the size of a button.
  6. That's it!

Example

//In Mainframe.h
#define TOOLBAR_DRAW_BUTTON_WIDTH 24
#include "TrueColorToolBar.h"
class CMainFrame : public CFrameWnd
{
    CTrueColorToolBar m_ToolBarDrawLeft;
}

//In Mainframe.cpp
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
        return -1;

    if (!m_ToolBarDrawLeft.Create(this, WS_CHILD | 
        WS_VISIBLE | CBRS_LEFT  | CBRS_GRIPPER | 
        CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
        !m_ToolBarDrawLeft.LoadToolBar(IDR_TOOLBAR_DRAW))
    {
        TRACE0("Failed to create toolbar\n");
        return -1; //Failed to create
    }

    //Add bitmap to toolbar
    m_ToolBarDrawLeft.LoadTrueColorToolBar(
        TOOLBAR_DRAW_BUTTON_WIDTH,
        IDB_TOOLBAR_DRAW,
        IDB_TOOLBAR_DRAW_HOT,
        IDB_TOOLBAR_DRAW_DISABLED);

    //Add DropDown Button
    m_ToolBarDrawLeft.AddDropDownButton(this, ID_BUTTON1, IDR_MENU1);

    return 0;
}

Conclusion

Note also that in the function LoadTrueColorToolBar, if you omit the last parameter for disabled toolbar, you will get a default embossed disabled toolbar. Enjoy!

License

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

About the Author

DCUtility

Other
DCUtility
Canada Canada

Member
Home Page

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralIs it possible to change a button's image at runtime Pinmembermiggedy6:24 7 Sep '10  
Questionhow can I change the background of buttons? Pinmemberwanglinhai88822:33 29 Dec '09  
GeneralWhen using dialog it gives me a memory leak. Pinmembermensfort3:35 2 Mar '09  
GeneralWhen using dialog it gives me a memory leak. Pinmembermensfort3:34 2 Mar '09  
GeneralWhen using dialog it gives me a memory leak. Pinmembermensfort3:33 2 Mar '09  
GeneralGreat,, Just What I've Been Wanting PinmemberMember 36507842:26 6 Nov '08  
Questioncompiler error Pinmembermatangoldman7:02 23 May '08  
AnswerRe: compiler error Pinmembermerano14:46 29 Mar '09  
QuestionNo TOOLTIPS? Pinmemberalex_tver14:25 4 Jan '08  
QuestionGreat!!! How can I disable/enable buttons? PinmemberRomiks5:45 7 Jun '07  
AnswerRe: Great!!! How can I disable/enable buttons? PinmemberDCUtility15:47 7 Jun '07  
AnswerRe: Great!!! How can I disable/enable buttons? PinmemberPaul Sanders (AlpineSoft)9:16 26 Oct '07  
GeneralThanks PinmemberPJ Arends9:58 13 Sep '06  
QuestionHow to replace the default toolbar? Pinmemberli00005:24 3 Jun '06  
QuestionLicense? Pinmemberjuraitwaluzka18:35 30 May '06  
Generalvs2005 compiler error Pinmemberbanbanyy5:19 19 Jan '06  
AnswerRe: vs2005 compiler error Pinmemberakaworks11:59 1 Feb '06  
GeneralBMP at BackGround Pinmemberextus15:00 17 Sep '04  
Does anyone know if i can put a BackGround Image to the white area of an SDI application. if(yes)
{
Can you tell me how i do it;
}
else
{
nevermind;
}
Smile | :)
QuestionHelp! Why these happened? Pinmemberyoufly3:10 22 Jun '04  
AnswerRe: Help! Why these happened? Pinmemberabiendl1:35 2 Oct '04  
GeneralButton to big with drop-down Pinmemberquzi3:53 30 Apr '04  
QuestionGood job,but how can i show text on the button? Pinmemberjoxoy0:26 30 Apr '04  
AnswerRe: Good job,but how can i show text on the button? Pinmemberquzi1:12 30 Apr '04  
GeneralRe: Good job,but how can i show text on the button? Pinmemberjoxoy16:42 7 May '04  
GeneralRe: Good job,but how can i show text on the button? PinmemberEinst17:52 9 Jan '06  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120210.1 | Last Updated 28 Jan 2003
Article Copyright 2003 by DCUtility
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid