Click here to Skip to main content
Licence CPOL
First Posted 20 Aug 2002
Views 182,184
Downloads 7,383
Bookmarked 68 times

CTrueColorToolBar

By DCUtility | 21 Aug 2002
Very simple true color toolbar (It's true!)

1

2
1 vote, 6.7%
3
3 votes, 20.0%
4
11 votes, 73.3%
5
4.70/5 - 23 votes
1 removed
μ 4.51, σa 1.08 [?]

Sample Image - TrueColorToolBar.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;
    m_ToolBarDrawLeft.SetBorders(1, 1, 
        1, 1); //Fix for WinXP

    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
    }

    m_ToolBarDrawLeft.ModifyStyle(0, 
        TBSTYLE_FLAT);//Fix for WinXP
    m_ToolBarDrawLeft.LoadTrueColorToolBar(
        TOOLBAR_DRAW_BUTTON_WIDTH,
        IDB_TOOLBAR_DRAW,
        IDB_TOOLBAR_DRAW_HOT,
        IDB_TOOLBAR_DRAW_DISABLED);
    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
Questionbug in docking... Pinmembermsh_kr4:07 29 Aug '11  
GeneralMy vote of 3 PinmemberKarstenK1:39 29 Oct '10  
Generaladding text PinmemberJabraJabra0:20 9 Jul '04  
Generalusing CTrueColorToolBar Pinsusssatadru2:05 15 Dec '03  
GeneralGDI leak Pinmembermanero4:33 1 Jul '03  
GeneralAdding text to toolbar Pinmemberahmad0110:49 29 May '03  
GeneralRe: Adding text to toolbar Pinmemberluca diciotti0:05 10 Jun '03  
GeneralRe: Adding text to toolbar PinmemberEric Forget9:36 17 Nov '03  
GeneralRe: Adding text to toolbar Pinmemberluca diciotti22:42 17 Nov '03  
GeneralProblem with TBSTYLE_AUTOSIZE PinmemberZebster3:26 26 Feb '03  
GeneralRe: Problem with TBSTYLE_AUTOSIZE PinmemberZebster3:47 26 Feb '03  
GeneralTransparency issue on checked state Pinmemberrb264:59 28 Jan '03  
GeneralRe: Transparency issue on checked state PinmemberDany Cantin5:27 28 Jan '03  
GeneralRe: Transparency issue on checked state Pinmemberrb265:47 28 Jan '03  
Generalwhere is the Flat PinmemberGozhhu20:27 23 Jan '03  
Generalhelp with the drop arrow! PinmemberMingming Lu21:12 9 Jan '03  
GeneralRe: help with the drop arrow! PinmemberDany Cantin13:46 13 Jan '03  
QuestionAfxGetInstanceHandle vs. AfxGetResourceHandle? PinmemberFranck Pascutti1:33 13 Dec '02  
GeneralToolBarCtrl help PinmemberAnthonyWinters10:31 30 Oct '02  
GeneralRe: ToolBarCtrl help PinmemberDany Cantin10:55 30 Oct '02  
GeneralRe: ToolBarCtrl help PinmemberAnthonyWinters12:30 30 Oct '02  
GeneralRe: ToolBarCtrl help PinmemberAnthonyWinters13:28 30 Oct '02  
GeneralRe: ToolBarCtrl help PinmemberDany Cantin6:10 31 Oct '02  
QuestionCan tell me the truth? PinmemberLove In Snowing3:00 23 Aug '02  
AnswerRe: Can tell me the truth? PinmemberDany Cantin3:43 23 Aug '02  

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
Web02 | 2.5.120206.1 | Last Updated 22 Aug 2002
Article Copyright 2002 by DCUtility
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid