Click here to Skip to main content
11,922,789 members (53,113 online)
Click here to Skip to main content
Add your own
alternative version


287 bookmarked

Rich OutlookBar in XP and Vista style

, 2 Aug 2007 CPOL
Rate this:
Please Sign up or sign in to vote.
Creating a rich OutlookBar in XP or Vista style

Screenshot - NewScreenCapture.jpg


I've always enjoyed using a control that behaves like the OutlookBar in Outlook. After testing and creating this, I knew that if I wanted other people to work intuitively with my programs, the OutlookBar control must look and work like the one in Outlook.

Needed properties

The control must be functional and accessible during runtime, as well as in design mode. You can resize the control in design time, so you can choose which buttons will be displayed as large buttons. The buttons can be added and changed using a collection editor. During runtime, the DropDown icon opens a context menu where you can choose which buttons will be visible. You also can open a "Navigation Pane Options" form where you can reorder the buttons.

At runtime, mouse movements must cause the buttons to repaint if needed. There are different color schemes for hovering buttons. I need large buttons and small buttons, displayed in the correct order even after resizing the control. I also want to be able to set a button in a "not allowed" state. Depending on the user of your program, you can disable certain buttons. The difference between Allowed and Enabled is that with the Allowed property set to False, you cannot see the button.

Basic structure

There are three classes in this control:

Class OutlookBarButton

This represents the instances of the separate buttons. No painting occurs in this class. The basic members of this class are:

  • Text: this is the text drawn on the button if it's in a large state. If the button is at the bottom of the control, a tooltip will be displayed with the text of the button.
  • Visible: when False, the button will not be visible in the control. You can change this value at runtime with ContextMenu using the DropDown icon.
  • Allowed: when False, this button will not be visible in the control. You cannot access this button at runtime, so you can prevent certain users from clicking a certain button.
  • Image: the image that will be displayed. It works best with a 24x24 icon or larger.
  • Rectangle: this is only accessible in the assembly. When the OutlookBar class calculates where to draw the buttons, it will give each button the rectangle that OutlookBar used to draw it. Thanks to this property, it's easy to find out which button is clicked or which button must be repainted using different colors.

Class OutlookBarButtonCollection

Representing the collection of buttons on the control, this inherits from CollectionBase. In the code, you just use the normal procedures to add or remove buttons to the control:

Dim newButton as New Altea.OutlookBarButton
With newButton
    .Text="my button"
End With

Or using the overloaded constructor:

Me.OutlookBar1.Buttons.Add(New Altea.OutlookBarButton("my button", 

Class OutlookBar

Inheriting from System.Windows.Forms.Control, this is the main class. You have a property called Renderer with two options: Office2003 and Office2007. In a future version, there will be a third option called Custom. You can select a button from the code:

Me.OutlookBar1.Buttons("Journal").Selected = True

This class has the most events. Events such as MouseMove, MouseDown, MouseLeave, etc. will be handled in this class. The painting also happens in this class. OutlookBar will decide which ButtonState the buttons have depending on which user action has happened:

Friend Enum ButtonState
End Enum 

The ButtonState will raise the Paint methods to use the correct colors and cursor. In the painting code, there will often be references to several rectangles. Here's an overview with this image:

Screenshot - CaptureStructure_edit.JPG


Try it, run it and tell me about it!


  • 10/02/2007: Original version posted
  • 14/07/2007: Reduced flickering, added custom rendering for colors and button height
  • 02/08/2007: Download updated


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


About the Author

Star Vega
Software Developer
Belgium Belgium
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralRelicensing request Pin
roldn8-Sep-10 14:39
memberroldn8-Sep-10 14:39 
GeneralPorted C# code [modified] Pin
Andriy Protskiv6-Jan-10 3:21
memberAndriy Protskiv6-Jan-10 3:21 
Great control! Thank you!
I just ported it to C#.

modified on Tuesday, September 21, 2010 4:59 AM

GeneralThanks... Excellent piece of code! Pin
sglugove11-Dec-09 7:27
membersglugove11-Dec-09 7:27 
GeneralC# version Pin
Star Vega21-Sep-09 3:34
memberStar Vega21-Sep-09 3:34 
GeneralC# Version Please!!!!! Pin
mattdbuk21-Sep-09 2:53
membermattdbuk21-Sep-09 2:53 
AnswerRe: C# Version Please!!!!! Pin
Star Vega21-Sep-09 3:46
memberStar Vega21-Sep-09 3:46 
GeneralHelp for use RighToLeft property Pin
MammadAlimoradi24-Aug-09 8:59
memberMammadAlimoradi24-Aug-09 8:59 
GeneralTroubles in Visual Basic 2008 Pin
His_Royal_Dudeness30-Jul-09 8:56
memberHis_Royal_Dudeness30-Jul-09 8:56 
GeneralRe: Troubles in Visual Basic 2008 [modified] Pin
pimb230-Aug-09 2:05
memberpimb230-Aug-09 2:05 
GeneralSome questions .. Pin
Rodo3-Jul-09 14:43
memberRodo3-Jul-09 14:43 
GeneralRe: Some questions .. Pin
Jiong Mai22-Jul-09 5:09
memberJiong Mai22-Jul-09 5:09 
GeneralC# Version Pin
murali_212-Jun-09 0:31
membermurali_212-Jun-09 0:31 
GeneralRe: C# Version Pin
catu13-Jul-09 12:25
membercatu13-Jul-09 12:25 
QuestionHow to handle button click event ? Pin
Member 113344011-Apr-09 19:59
memberMember 113344011-Apr-09 19:59 
AnswerRe: How to handle button click event ? Pin
superkuton11-Jul-09 22:47
membersuperkuton11-Jul-09 22:47 
GeneralExcellent Pin
martin_hughes10-Apr-09 8:51
membermartin_hughes10-Apr-09 8:51 
GeneralRe: Excellent Pin
Star Vega10-Apr-09 8:58
memberStar Vega10-Apr-09 8:58 
GeneralAdd Sub Item Pin
kaleeswaramurthy25-Mar-09 19:41
memberkaleeswaramurthy25-Mar-09 19:41 
QuestionCode in C# Pin
jdkulkarni6-Jan-09 21:20
memberjdkulkarni6-Jan-09 21:20 
AnswerRe: Code in C# Pin
jdkulkarni6-Jan-09 23:55
memberjdkulkarni6-Jan-09 23:55 
GeneralRe: Code in C# Pin
shuami13-Jan-09 16:20
membershuami13-Jan-09 16:20 
QuestionVisual C++ or C# Version PLEASE? Pin
CarlBenton20-Nov-08 18:08
memberCarlBenton20-Nov-08 18:08 
GeneralDoes anybody have the C# version Pin
Andy ufuris11-Sep-08 12:44
memberAndy ufuris11-Sep-08 12:44 
GeneralSaving your added buttons? [modified] Pin
planocz1-Sep-08 11:19
memberplanocz1-Sep-08 11:19 
GeneralRe: Saving your added buttons? Pin
Daniel12318-Jul-09 14:44
memberDaniel12318-Jul-09 14:44 
AnswerHere's the C# version ... Pin
Angelo Cresta20-Aug-08 6:12
memberAngelo Cresta20-Aug-08 6:12 
GeneralRe: Here's the C# version ... Pin
shuami9-Sep-08 21:03
membershuami9-Sep-08 21:03 
GeneralRe: Here's the C# version ... Pin
mattdbuk21-Sep-09 2:37
membermattdbuk21-Sep-09 2:37 
GeneralC# Version Pin
Bigdream8-Jun-08 4:21
memberBigdream8-Jun-08 4:21 
GeneralC# Pin
razhia25-May-08 16:58
memberrazhia25-May-08 16:58 
GeneralC# Pin
JCBBath15-May-08 5:10
memberJCBBath15-May-08 5:10 
GeneralSliding Pin
Bjaquila4-Apr-08 6:01
memberBjaquila4-Apr-08 6:01 
GeneralForeColorHovering Pin
Jazza514531-Jan-08 3:55
memberJazza514531-Jan-08 3:55 
Generalc# Pin
wedding1236-Jan-08 21:38
memberwedding1236-Jan-08 21:38 
GeneralLicence Pin
Bostjan Gajsler5-Dec-07 1:49
memberBostjan Gajsler5-Dec-07 1:49 
GeneralRe: Licence Pin
Jan Geerinckx19-Jan-08 11:57
memberJan Geerinckx19-Jan-08 11:57 
GeneralRe: Licence Pin
Noodles193220-Oct-08 7:00
memberNoodles193220-Oct-08 7:00 
GeneralRe: Licence Pin
Star Vega20-Oct-08 7:04
memberStar Vega20-Oct-08 7:04 
GeneralRe: Licence Pin
Graham Irons5-Nov-08 13:37
memberGraham Irons5-Nov-08 13:37 
GeneralC# Pin
Sk8tz20-Nov-07 23:50
memberSk8tz20-Nov-07 23:50 
AnswerRe: C# Pin
kris.allberry23-Nov-07 4:11
memberkris.allberry23-Nov-07 4:11 
GeneralProblem with Newer Version Pin
kolag11-Nov-07 20:05
memberkolag11-Nov-07 20:05 
GeneralEating up too much CPU. Pin
PJonDevelopment1-Oct-07 3:33
memberPJonDevelopment1-Oct-07 3:33 
QuestionRight to Left support please Pin
dhamenha25-Sep-07 0:58
memberdhamenha25-Sep-07 0:58 
GeneralRight to left support Pin
Mickey Ekstein7-Sep-07 12:38
memberMickey Ekstein7-Sep-07 12:38 
QuestiononCLick Event Pin
davidhoyle30-Aug-07 12:07
memberdavidhoyle30-Aug-07 12:07 
QuestionFont size for buttons? Pin
bjswift28-Aug-07 7:29
memberbjswift28-Aug-07 7:29 
AnswerRe: Font size for buttons? Pin
bjswift28-Aug-07 7:47
memberbjswift28-Aug-07 7:47 
GeneralRe: Font size for buttons? Pin
Jan Geerinckx30-Aug-07 6:37
memberJan Geerinckx30-Aug-07 6:37 
GeneralSuggestion Pin
MCAST7619-Aug-07 7:36
memberMCAST7619-Aug-07 7:36 

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

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

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.151125.1 | Last Updated 2 Aug 2007
Article Copyright 2007 by Star Vega
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid