Click here to Skip to main content
Licence CPOL
First Posted 15 Oct 2007
Views 149,912
Downloads 1,841
Bookmarked 305 times

WindowsVistaRenderer: A New Button Generation

By Jose Menendez Póo | 23 Nov 2007
ToolStripRenderer that renders Vista like buttons
2 votes, 1.6%
1
2 votes, 1.6%
2
1 vote, 0.8%
3
16 votes, 12.4%
4
108 votes, 83.7%
5
4.87/5 - 130 votes
5 removed
μ 4.75, σa 1.22 [?]
Screenshot - VistaRenderer.jpg

Introduction

This article demonstrates how to use the WindowsVistaRenderer and how it was created.

Background

Don't you miss the days when a button was drawn with a couple of lines to show a 3D effect? Drawing a button was as simple as drawing the light border and the shadow border. Those days are gone. Vista has arrived and our old apps may need to be renewed.

The first time you look at a button like the ones on Vista look and feel, you must feel dizzy. How to draw buttons like that? Well it turns out that it is not such a great deal. It took me a while to totally understand how these buttons are drawn, but I think the result is a good approach.

Using the Code

Thank God for the ToolStripRenderer technology.

To use this renderer on a ToolStrip you only need one line of code:

//
// Apply Windows Vista look and feel
//

toolStrip1.Renderer = new Renderers.WindowsVistaRenderer();

The Renderer initializes the necessary properties for the ToolStrip, except for the LayoutStyle property which I recommend to be the default HorizontalStackWithOverflow, otherwise the toolbar may look ugly in some cases.

The source solution contains a project named Renderers. Reference that DLL to your project or copy the source files to your project.

How to Draw a Button Like That

As I said before, the old-school buttons were drawn in a very easy way:

Screenshot - VistaRenderer1.gif Screenshot - VistaRenderer2.gif

The whole idea is to make the user think that he or she is really pushing a button, when clicked shadows were inverted, text pushed one pixel on x and one pixel on y, and the click effect was done.

The Vista buttons are way more complex. I've found different layers on the button drawing.

Borders

Three rounded rectangles are drown as a border, I call them the outer border, the border and the inner border.

Screenshot - VistaRenderer3.gif

Glossy Effect

A glossy effect is drawn on the north of the button. The green color represents an almost transparent color.

Screenshot - VistaRenderer4.gif

Glow

A radial gradient simulates a color glow on the south of the button. The green color represents an almost tansparent color.

Screenshot - VistaRenderer5.gif

Button Fill

Similar to the glossy effect, the inner border area is emphasized with a linear button fill from north to south.

Putting It All Together

Now, the order in which we draw these layers is critical. That order is:

  1. Outer border
  2. Button background color (if button is checked)
  3. Glossy effect
  4. Border
  5. Button fill glossy emphasis
  6. Inner border
  7. Glow
  8. Text and image of the button
Screenshot - VistaRenderer6.jpg

Some Other Details

To create the click effect, the color of the inner border and the button fill are changed. When clicked, the text is not pushed one pixel like in the old days.

When checked, the background color of the button changes. That color was extracted from the tabs on the MediaPlayer.

To make the toolbar a full-Vista-experience component, menus are drawn using the Windows Vista look and feel.

Credits

Thanks to Lukasz Swiatkowski for the methods on creating rounded rectangles and the bottom radial path.

History

  • 15 Oct 2007: Article creation
  • 25 Oct 2007: Subitem initialization by recursion solved (suggested by rvpilot)
  • 21 Nov 2007: Combobox and Textbox support. Better overflow chevron.
  • 23 Nov 2007: MenuStrip support.

License

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

About the Author

Jose Menendez Póo

Team Leader

Mexico Mexico

Member
Jose Manuel Menéndez Poó
 
- I've been programming Windows and Web apps since 1997.
- My greatest concern nowadays is user interface usability.
 
Jose Runs Techniks Software
www.techniks.com.mx
 
Blog
menendezpoo.com

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
QuestionBinaries PinmemberVercas3:55 21 Jun '11  
AnswerRe: Binaries PinmemberJose Menendez Póo4:05 21 Jun '11  
GeneralRe: Binaries PinmemberVercas4:21 21 Jun '11  
QuestionIs there a renderer with Windows 7 theme? Pinmemberstax761:48 14 Aug '09  
Generalnot properly recover default renderer PinmemberUnruled Boy16:36 17 Jan '09  
Generalmenu not properly rendered in windows 2003 PinmemberUnruled Boy15:43 17 Jan '09  
Questionrenderer in vb.net PinmemberJoeFisher716:35 6 Nov '08  
AnswerRe: renderer in vb.net PinmemberJose M. Menendez Poó7:36 6 Nov '08  
There's absolutely no problem as long as you mention my work.
 
Thanks for asking.
 
Remember to send me the link to the article! Looking forward to see it.
 
Jm
www.menendezpoo.com

General[Message Removed] PinmemberKatekortez10:08 25 Oct '08  
GeneralAbout new button generation Pinmembermarclenoir20057:27 1 Sep '08  
GeneralRe: About new button generation PinmemberJose M. Menendez Poó7:55 1 Sep '08  
QuestionLegal for commerical Application? PinmemberOmnicoder9:58 31 May '08  
QuestionThe control looks very good. Is there any way to implement the same look and feel in web pages of asp.net PinmemberMember 314494518:34 24 Feb '08  
AnswerRe: The control looks very good. Is there any way to implement the same look and feel in web pages of asp.net PinmemberThe Dogcow Farmer12:36 26 Jun '08  
QuestionLicence PinmemberJulian-w0:26 31 Dec '07  
GeneralFighting the tools PinmemberMount23:57 30 Dec '07  
QuestionHow do I do this with just the command buttons? PinmemberJonathanVQP7:55 19 Dec '07  
AnswerRe: How do I do this with just the command buttons? PinmemberThe Dogcow Farmer6:10 27 Jun '08  
GeneralTranslation to vb.net [modified] Pinmembervirtual.aussie11:13 26 Nov '07  
Generaljust move to WPF Pinmemberdimzon7:48 21 Nov '07  
AnswerRe: just move to WPF Pinmembermofle12:43 21 Nov '07  
GeneralRe: just move to WPF Pinmemberdimzon6:28 22 Nov '07  
GeneralRe: just move to WPF Pinmembermofle6:52 22 Nov '07  
GeneralRe: just move to WPF PinmemberThe_Mega_ZZTer6:12 23 Nov '07  
GeneralRe: just move to WPF Pinmembermofle6:18 23 Nov '07  

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.120210.1 | Last Updated 23 Nov 2007
Article Copyright 2007 by Jose Menendez Póo
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid