Languages ? VB.NET ? General

Licence CPOL
First Posted 10 Feb 2007
Views 171,195
Bookmarked 258 times
Tags .NET2.0, WinXP,Vista, VS.NET2003 ...

Rich OutlookBar in XP and Vista styleBy Star Vega | 2 Aug 2007 Creating a rich OutlookBar in XP or Vista style

Prize winner in Competition "Best VB.NET article of Jan 2007"

Print Article

Twitter

Digg

Facebook

Del.icio.us

Reddit

Stumbleupon

Newsvine

Technorati

Mr. Wong

Yahoo!

Google

Windows Live

Send as Email Add to your CodeProject bookmarks

Discuss this article115

Report this article as inappropriate

Article Browse Code Stats Revisions

4.78 (79 votes)

1

2

3

4

5

Sponsored Links See Also

  • Articles like this
  • Articles by this author
  • Download source code - 784.2 Kb
  • Introduction

    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:

    Collapse | Copy Code

    Dim newButton as New Altea.OutlookBarButton With newButton .Text="my button" .Visible=False .Image=My.Resources.myImage End With me.OutlookBar1.Buttons.Add(newButton)

    Or using the overloaded constructor:

    Collapse | Copy Code

    Me.OutlookBar1.Buttons.Add(New Altea.OutlookBarButton("my button", My.Resources.myImage))

    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:

    Collapse | Copy 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:

    Collapse | Copy Code

    Friend Enum ButtonState Passive Hovering Selected 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:

    Conclusion

    Try it, run it and tell me about it!

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

    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

    BelgiumMember

    Article Top

    Sign Up to vote for this article

    Add a reason or comment to your vote: x

    Comments and Discussions

    You must Sign In to use this message board.

    FAQ

    Noise ToleranceLayoutPer page
    Msgs 1 to 25 of 115 (Total in Forum: 115) (Refresh) FirstPrevNext

    Relicensing request

    roldn 14:39 8 Sep "10

    Ported C# code [modified]

    Andriy Protskiv 3:21 6 Jan "10

    Thanks... Excellent piece of code!

    sglugove 7:27 11 Dec "09

    C# version

    Star Vega 3:34 21 Sep "09

    C# Version Please!!!!!

    mattdbuk 2:53 21 Sep "09

    Re: C# Version Please!!!!!

    Star Vega 3:46 21 Sep "09

    Help for use RighToLeft property

    MammadAlimoradi 8:59 24 Aug "09

    Troubles in Visual Basic 2008

    His_Royal_Dudeness 8:56 30 Jul "09

    Re: Troubles in Visual Basic 2008 [modified]

    pimb2 2:05 30 Aug "09

    Some questions ..

    Rodo 14:43 3 Jul "09

    Re: Some questions ..

    Jiong Mai 5:09 22 Jul "09

    C# Version

    murali_21 0:31 2 Jun "09

    Re: C# Version

    catu 12:25 13 Jul "09

    How to handle button click event ?

    Member 1133440 19:59 11 Apr "09

    Re: How to handle button click event ?

    superkuton 22:47 11 Jul "09

    Excellent

    martin_hughes 8:51 10 Apr "09

    Re: Excellent

    Star Vega 8:58 10 Apr "09

    Add Sub Item

    kaleeswaramurthy 19:41 25 Mar "09

    Code in C#

    jdkulkarni 21:20 6 Jan "09

    Re: Code in C#

    jdkulkarni 23:55 6 Jan "09

    Re: Code in C#

    shuami 16:20 13 Jan "09

    Visual C++ or C# Version PLEASE?

    CarlBenton 18:08 20 Nov "08

    Does anybody have the C# version

    Andy ufuris 12:44 11 Sep "08

    Saving your added buttons? [modified]

    planocz 11:19 1 Sep "08

    Re: Saving your added buttons?

    Daniel123 14:44 18 Jul "09

    Last Visit: 3:40 21 Dec "10 Last Update: 5:15 21 Dec "10 12345 Next ?

    General

    News

    Question

    Answer

    Joke

    Rant

    Admin

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

    PermaLink | Privacy | Terms of Use Last Updated: 2 Aug 2007Copyright 2007 by Star VegaEverything else Copyright ? CodeProject, 1999-2010 Web23 | Advertise on the Code Project ArcGIS ExplorerArcGIS Explorer is a free downloadable...www.esri.com ATI Stream SDKThe ATI Stream Software Development Kit (SDK)...developer.amd.com BinaryVirtualizingWrapPanel .NETBinaryVirtualizingWrapPanel .NET is a UI...www.binarymission.co.uk See Also...Creating PDF Documents in ASP.NETHow to create PDF documents in ASP.NET.A Fast CSV ReaderA reader that provides fast, non-cached,...A Simplified SQL-CSV Import/Export FunctionalityA simplified SQL-CSV import/export functionality.Importing CSV Data and saving it in databaseThis article shows how to import CSV data and...Transferring Data Using SqlBulkCopyAn article on how to transfer data using...Announcements

    Mobile Virtual Tech Summit On Demand

    Got an Azure app? Win an Xbox & Kinect

    The Daily Insider30 free programming booksDaily News: Signup now.


    推薦閱讀:

    查看原文 >>
    相关文章