5,698,535 members and growing! (18,661 online)
Email Password   helpLost your password?
Desktop Development » Menus » Toolbars     Intermediate

Rebar Control Wrapper in C#

By Anthony Baraff

C# Wrapper for the Microsoft Rebar Control
C#Windows, .NET, .NET 1.0, NT4, Win2K, WinXPVS.NET2002, Visual Studio, Dev

Posted: 9 May 2002
Updated: 9 May 2002
Views: 186,708
Bookmarked: 71 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
26 votes for this Article.
Popularity: 6.44 Rating: 4.55 out of 5
1 vote, 5.0%
1
0 votes, 0.0%
2
0 votes, 0.0%
3
4 votes, 20.0%
4
15 votes, 75.0%
5

Sample Image - rebarcontrol.jpg

Introduction

When Microsoft released its .NET framework I’m sure that many of you were as surprised as I was that the Rebar or “Coolbar” control was not included. So, I fired up the Customize Toolbar window and added the Microsoft Coolbar Control (everyone knows that .NET works perfectly with COM). Maybe your results were different than mine, but I found the wrapped version to be completely useless. I couldn’t find any way to add child controls or attach them to bands. I briefly fiddled with COM interop, but that seemed to be a dead end. The end result was that I decided to implement a .NET Rebar control using the ll and native API calls.


First of several Disclaimers

The code is functional, but not all of the bugs have been fixed. There is a bunch of stuff that hasn’t been completed at this point (chevron functionality; certain properties; some Unicode stuff; a resizing bug; problems with MouseEnter, MouseHover and MouseLeave; comments in the source…), but I’ll periodically post updates along the way.


About the control Source Code

This is the first control I’ve developed using C#, and it’s also one of my first few C# projects. Please, keep that in mind when reviewing the code. Along the way I found that frequently there were better ways of doing things. In most (but not all) cases I fixed the code. There’s also a fair amount of unused code lying around. I’ll clean it up when I get a chance. That said, the source code may still be interesting to programmers who are looking for sample code covering one or more of the following areas: Windows API Calls, Control Attributes, the ControlDesigner class, CollectionBase class, Component class, Control class, CollectionEditor class and/or Windows Messages.


Using the RebarWrapper Control

Using the Rebar should be relatively self explanatory. Drop it into your form using the toolbox. The initial instance is created without any bands. To add bands, click on the Bands property of the RebarWrapper in the Property Browser. The Bands Collection Editor will allow you to Add, Remove and Edit the Rebar Bands. Each Band’s properties are controlled via a BandWrapper Component. As you add bands you’ll see them pile up in the component tray at the bottom of the Form Designer. Clicking on a band in the Rebar brings up the Rebar’s properties in the Property Browser. It does not select the BandWrapper Component. Use the dropdown at the top of the Property Browser, Band Collection Editor or the icon in the component tray to access the band’s property.

Each Band can act as the Parent for one control (although this can be circumvented by hosting several controls inside of a panel or other container control). Designate the control to be parented by editing the Child property of the band. For the control to behave properly, the child control must be parented by the RebarWrapper control. Use the MinHeight and MinWidth properties to size the band to fit the control it is parenting.


Conclusion and Final Disclaimer

Play around with the various properties, events and settings. I’d be very interested to hear about any improvements/fixes/adaptations. As I mentioned before, I’ll try to take care of bug fixes when I have the time and interest, but use this code at your own risk. Future versions may drop or add functionality, not be compatible with the old version, or never be developed at all. With all that said, enjoy.

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

Anthony Baraff



Occupation: Web Developer
Location: United States United States

Other popular Menus articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 25 of 32 (Total in Forum: 32) (Refresh)FirstPrevNext
GeneralFor .NET 2.0 / VS2005 usersmemberPatrick Sears7:49 8 Mar '07  
NewsHow to show chevronmemberjefrubio1:45 28 Apr '06  
GeneralChevron and menubar (like IE) for Rebarmembervinod ms0:30 26 Oct '05  
GeneralAPI and struct definitionsmemberChristian Wikander23:42 19 Aug '04  
GeneralRe: API and struct definitionsmembermav.northwind21:21 31 Aug '04  
GeneralRe: API and struct definitionsmemberChristian Wikander23:03 1 Sep '04  
GeneralRe: API and struct definitionsmembermav.northwind23:14 1 Sep '04  
GeneralWidbey?membercoderforrent11:10 3 May '04  
GeneralRe: Widbey?sussAnonymous2:13 14 Jan '05  
Generalresize width in runtime with vertical rebarmemberjax223:10 25 Mar '04  
GeneralPossible to make this a floating toolbar?sussartesano4:14 15 Sep '03  
GeneralIs this control bug free?memberMelvin Ng0:49 12 Sep '03  
GeneralMulti-band drawing is not correct when the winform is minimized and restoredmemberRadeon@lab-a21:13 26 Aug '03  
GeneralRe: Multi-band drawing is not correct when the winform is minimized and restoredmemberDem9:53 28 Oct '03  
GeneralFound a bugmemberdacris21:04 20 Aug '03  
GeneralYou could do this without API'smemberChris Pietschmann20:47 22 Jul '03  
GeneralRe: You could do this without API'smemberChristian Wikander23:10 15 Aug '04  
GeneralRe: You could do this without API'smembercrpietschmann16:34 17 Aug '04  
GeneralRe: You could do this without API'smemberJoe McConnell8:51 29 Jun '06  
GeneralBand Positioningmember9ballrulz12:05 22 May '03  
GeneralAbout CollectionEditmemberhbchen3321:39 16 May '03  
Generalabout floating toolbarmemberhbchen3321:35 16 May '03  
GeneralExcellent work!memberRadeon@lab-a0:04 8 May '03  
GeneralVertical Display?membermikeyd4:13 2 Mar '03  
GeneralRe: Vertical Display?memberSrinivasa Raghavan0:00 28 Mar '03  

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

PermaLink | Privacy | Terms of Use
Last Updated: 9 May 2002
Editor: Chris Maunder
Copyright 2002 by Anthony Baraff
Everything else Copyright © CodeProject, 1999-2008
Web13 | Advertise on the Code Project