$BlogRSDURL$>
This blog will describe some of the learning experiences that I have with .NET, some personal projects that I'm working on, and whatever other topics tickle my fancy.
My Blog LinksSite Links
Currently ReadingBlogroll
Archives
Tools |
Thursday, March 11, 2004FlatTabControl Sample
Overall, the WinForms TabControl gives you a lot of customization through its owner draw mechanism. You can paint the tab buttons basically in whatever way you want. However, the background color behind the page tabs cannot be changed, and neither can the 3D button effect around the control and the page tab buttons. So, for an application that I'm working on, I wanted to be able to fully customize the drawing of the background and have a flat rather than 3D control
So another control that I have in my Control library on GotDotNet is a FlatTabControl. This control allows the user to specify what the ControlBackColor and the TextColor. These colors are then used during the control's painting. Also, it allows for a BorderDarkColor and BorderLightColor which are used to paint both the border around the control and the borders for the tab buttons. Here's a look at what I mean. The control on the right is the standard WinForms TabControl, but it's customized as much as possible with a different color scheme. As you can see, portions of it still have basic control look and feel. On the left is my FlatTabControl. It paints everything in the appropriate color scheme, so that you can fully customize your user interface. The interesting part to get the painting to be overridden was in the constructor to tell the underlying control that I wanted to handle all of the painting (including the borders and background):
Then, I override OnPaint to draw in what I want. In OnPaint, I broke up the painting into different steps:
These methods are all exposed as virtual, so that anyone can derive from the FlatTabControl and customize any of the specific drawing steps that they're interested in. Want to just change how the button borders are drawn, then just override the DrawButtonBorder method. Also, to continue to support the owner draw mechanism and allow customization in that way, the PerformDrawItem method fires the DrawItem event, if the DrawMode property is set to OwnerDraw. Note: I turned off being able to set the TabAlignment to Left or Right because for my project, all I needed was the Top and Bottom. If you need others, it shouldn't be too hard to add. I may even do it in the future, if I ever need it. Also, you can download the full sample code from GotDotNet or look at it online and report bugs at the workspace.
Comments:
Accutane - Do You Really Want to Risk It?
Post a Comment
Acne & Pimples Treatment Acne - Four Causes of Adult Acne Acne - Skin Care, Treatment and Remedies Acne - The Pros and Cons of Oral Antibiotic Therapy Acne Aging Problem Acne and Dry Skin - A Tough Combination Acne and Oily Skin Care Treatment - Reduce Oil and Clear Acne Acne and Retin A - Does Retin A Cure Acne and Acne Scars? Acne and Traditional Chinese Medicine Acne Antibiotic Treatment - Cures Acne With A Difference Acne Blemish Control - 3 Acne Blemish Control Masks For Great Looking Skin Acne Blemish Control - Discover Three Effective Masks For Getting Rid of Acne Acne Blemish Laser Treatment - Laser Away Acne Blemishes Acne Blemish Treatment Acne Blemishes - Top 5 Zit Tips Acne Body Wash That Really Works Acne Care - Laser Treatment Can Help Cure Acne Acne Causes and Effective Natural Treatment Acne Cleanser to Help Protect Your Skin - Adios Nightmares! Acne Clear Light Treatment - At Last! No Side Effects! Acne Clearing Herbs That Help to Cure Acne and Treat Pimples Acne Complex Vs Proactiv Solution Acne Cream Treatment - 3 Effective Creams to Treat Your Acne Acne Cure That Works - Simple Products For Acne Treatment & Fast Solutions to Get Rid of Pimples |