Click here to Skip to main content
6,306,412 members and growing! (16,478 online)
Email Password   helpLost your password?
Desktop Development » Toolbars & Docking windows » Toolbars     Intermediate License: The Code Project Open License (CPOL)

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

By DCUtility

This is TrueColor Toolbar class
VC6, VC7Win2K, WinXP, MFC, Dev
Posted:27 Jan 2003
Views:119,098
Bookmarked:68 times
Announcements
Loading...
 
Search    
Advanced Search
printPrint   Broken Article?Report       add Share
  Discuss Discuss   Recommend Article Email
33 votes for this article.
Popularity: 6.92 Rating: 4.56 out of 5
2 votes, 6.1%
1

2

3
8 votes, 24.2%
4
23 votes, 69.7%
5

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


Member
Home Page
Occupation: Software Developer
Company: DCUtility
Location: Canada Canada

Other popular Toolbars & Docking windows articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 25 of 33 (Total in Forum: 33) (Refresh)FirstPrevNext
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  
GeneralNo TOOLTIPS? Pinmemberalex_tver14:25 4 Jan '08  
GeneralGreat!!! How can I disable/enable buttons? PinmemberRomiks5:45 7 Jun '07  
GeneralRe: Great!!! How can I disable/enable buttons? PinmemberDCUtility15:47 7 Jun '07  
GeneralRe: Great!!! How can I disable/enable buttons? PinmemberPaul Sanders (AlpineSoft)9:16 26 Oct '07  
GeneralThanks PinmemberPJ Arends9:58 13 Sep '06  
GeneralHow to replace the default toolbar? Pinmemberli00005:24 3 Jun '06  
GeneralLicense? 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  
GeneralHelp! Why these happened? Pinmemberyoufly3:10 22 Jun '04  
GeneralRe: Help! Why these happened? Pinmemberabiendl1:35 2 Oct '04  
GeneralButton to big with drop-down Pinmemberquzi3:53 30 Apr '04  
GeneralGood job,but how can i show text on the button? Pinmemberjoxoy0:26 30 Apr '04  
GeneralRe: 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  
Generaldisable button Pinmemberquzi20:49 1 Apr '04  
Generaldynamical drop down menu Pinmemberquzi20:26 28 Mar '04  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 27 Jan 2003
Editor: Smitha Vijayan
Copyright 2003 by DCUtility
Everything else Copyright © CodeProject, 1999-2009
Web20 | Advertise on the Code Project