Click here to Skip to main content
Click here to Skip to main content

Bitmap ToolBar

By , 25 Apr 2002
 

Sample Image - screen.jpg

Introduction

This is my attempt to create a simple toolbar class that allows to set a bitmap in the background of a toolbar. It is not as successful as the BCGControl lib but that's a beginning...

Some improvements could be made; for example, a hot image is not used. The process also flickers a little when clicking a button. The class should also be modified to Load the background only once to update only the buttons rect.

To use

  • Create the toolbar as usual:
    if (!myToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
    		| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, 
    		DB_BITMAP_TAHITI, IDB_BITMAP_TOOLBAR, 9, false) ||
    		!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
    {
    	TRACE0("Failed to create toolbar\n");
    	return -1;      // fail to create
    }

    DB_BITMAP_TAHITI = id of the background bitmap.
    IDB_BITMAP_TOOLBAR = id of the toolbar bitmap.
    9 is the number of buttons of the bitmap.
    false is a boolean that define if the background bitmap must be stretched if its size is different of the toolbar.

    Note that TBSTYLE_FLAT will create flat format buttons... else, standard 3D buttons will be added.

  • Set the style of the process, IM_STRECH or IM_TRANSPARENT. IM_TRANSPARENT will take the toolbar image as it is and remove the background color. IM_STRECH stretch the bitmap to the size of the button.
    m_wndToolBar.ImageStyle = IM_TRANSPARENT;
    m_wndToolBar.MaskColor = RGB(198, 195, 198);
  • Define if the bitmap must be applied on the complete control frame or only on the toolbar. m_wndToolBar.all_frame = true;

  • You can modify the type of button with the DrawEdge function's options.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Nicolas Gazelle
Web Developer
Monaco Monaco
Member
No Biography provided

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.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralIs it possible on C#memberInquire2you3 Sep '04 - 14:11 
Anyone know is it possible on C# ?
If it is possible, how to do ?
 
Thank you
GeneralRe: Is it possible on C# Pinmemberchengser14 Aug '05 - 19:16 
这个是不可能的,每一个语言都有自己的特定之处!
I thing it can't
AnswerRe: Is it possible on C# PinmemberThe Dogcow Farmer9 Jul '08 - 6:30 
Use the ToolStrip class.
 
"What's everyone so worked up about? So there's a comet -- big deal. It'll burn up in our atmosphere and what's ever left will be no bigger than a chihuahua's head." - Homer Simpson

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

Permalink | Advertise | Privacy | Mobile
Web03 | 2.6.130523.1 | Last Updated 26 Apr 2002
Article Copyright 2002 by Nicolas Gazelle
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid