Click here to Skip to main content
15,885,742 members
Articles / Programming Languages / Visual Basic
Article

A Visual Studio 2005-like Interface

Rate me:
Please Sign up or sign in to vote.
4.89/5 (167 votes)
22 Jan 2007CPOL4 min read 1.1M   11K   503   252
Apply a theme that resembles Visual Studio 2005 to the DockPanel Suite, using an Extender class.
Sample Image - DockPanelSkin.png

Overview

It's now been awhile since programs like Opera, Firefox and other software introduced MDI tabbed interfaces. Unluckily, there are not too many free components that allow .NET developers to create such interfaces. I was searching the internet for a long time before discovering the DockPanel Suite, a wonderful and fully customizable component from Weifen Luo. This component is available on Sourceforge, here.

Introduction

This article shows how the DockPanel component can be customized, implementing an Extender class. The attached example creates a Visual Studio 2005 like interface against version 1.0 of the DockPanel.

Copyright

Weifen Luo is the owner of the copyright for the DockPanel Suite, which includes the Extender class, the object of this article.

Background

This article is based around the DockPanel Suite library and it requires at least a basic knowledge of this. Please refer to the References paragraph to find more information about it. A good knowledge of the System.Drawing classes and functions is also required.

The Extender Class

DockPanel accepts customizations through five classes:

  • AutoHideTab represents a single tab used when the content is in the autohide state.
  • AutoHideStrip draws tabstrips and tabs when the content is in the autohide state.
  • DockPaneCaption draws the caption pane when the contents are tool windows.
  • DockPaneTab represent a single tab used when the content is a document window or a tool window.
  • DockPaneStrip draws tabstrips and tabs when the content is a document window or a tool window.

For convenience, these classes are enclosed in an Extender class. The following sections describe the component parts and the relative modules you can customize.

AutoHideStrip and AutoHideTab

The autohide strips can appear at the four borders of the main form and they are activated by the MouseOver event. The tabstrip will be visible only if at least one content is in the autohide state. When the tabs are docked to the left or to the right, the resulting tabs are rotated 90 degrees.

Following is a screenshot of a form docked to the top:

Image 2

Here is another example of a form docked to the bottom:

Image 3

The drawing of tabstrips and tabs is done by the class AutoHideStripFromBase. The painting methods are mainly the following:

  • OnPaint handles the OnPaint event of the control.
  • DrawTabStrip draws the tabstrips with a right orientation and all the contained tabs.
  • DrawTab draws a single tab.

DockPaneCaption

DockPaneCaption represents the form border when the form is docked and it normally contains a title, a button to close the window and a button to set the window to the autohide state. The Visual Studio 2005 like interface also contains a button to manipulate the window state through a context menu.

The following is a screenshot of DockPaneCaption:

Image 4

The drawing of the caption is done by the class DockPaneCaptionFromBase. The painting methods are mainly the following:

  • OnPaint handles the OnPaint event of the control.
  • DrawCaption draws the background and the caption text.

DockPaneStrip and DockPaneTab

DockPaneStrip represents the tab area shown when the content is a tool window or a document. There are many differences between these two regarding the tab shape and other behaviour. An example is hiding the tabstrip in the case of a single content. The drawing of tabstrips and tabs is done by the class DockPaneStripFromBase. The following examples will clarify these differences.

Example of a tabstrip that shows document tabs:

Image 5

Example of a tabstrip that shows document tabs with an icon and the overflow symbol:

Image 6

Example of a tabstrip that shows tool window tabs:

Image 7

The painting methods for the document tabstrip are the following:

  • OnPaint handles the OnPaint event of the control.
  • DrawTabStrip_Document draws the background.
  • DrawTab_Document draws the shape, icon and text.

The painting methods for the tool window tabstrip are the following:

  • OnPaint handles the OnPaint event of the control.
  • DrawTabStrip_ToolWindow draws the background.
  • DrawTab_ToolWindow draws the shape, icon, and text.

Using the Code

To apply the Extender to an instance of DockPanel, insert the following code into the Form_Load event of your form, replacing the name of the control with yours.

VB
Extender.SetSchema(DockPanel1, Extender.Schema.FromBase)

Final Notes

I hope that you find this article useful. If you find this article stupid, annoying or incorrect, express this fact by rating the article as you see fit. In the end, you're very welcome at any moment to freely contribute to this project by suggesting improvements or by submitting code or other materials.

Credits

Thanks to Weifen Luo for providing the community with the DockPanel component. If you like this component, you may want to make a donation to Weifen Luo here.

References

History

  • 3rd June 2006: first submission
  • 20th July 2006: bug fix (the MdiParent property doesn't need to be set)
  • 20nd January 2007: updated download

License

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


Written By
Software Developer (Senior)
Italy Italy
I am 40 years old and I've been working with C++, Visual Basic .NET, C# and ASP.NET. I have a large experience in Industrial Automation solutions, but I've worked also as Web developer and DBA. I like to share knowledge and projects with other people.

Comments and Discussions

 
GeneralRe: intresting interface Pin
Danilo Corallo30-Dec-06 7:13
Danilo Corallo30-Dec-06 7:13 
GeneralSolution form doesn't resize correctly Pin
kevinlkingma1-Dec-06 11:01
kevinlkingma1-Dec-06 11:01 
GeneralC# Version Pin
stromboldt21-Nov-06 12:16
stromboldt21-Nov-06 12:16 
GeneralRe: C# Version Pin
Danilo Corallo30-Dec-06 7:27
Danilo Corallo30-Dec-06 7:27 
GeneralRe: C# Version Pin
doncapachino27-Feb-07 22:12
doncapachino27-Feb-07 22:12 
GeneralRe: C# Version Pin
Danilo Corallo27-Feb-07 22:19
Danilo Corallo27-Feb-07 22:19 
GeneralMessage Closed Pin
DomGries14-Nov-06 4:29
DomGries14-Nov-06 4:29 
AnswerMessage Closed Pin
14-Nov-06 5:56
DomGries14-Nov-06 5:56 
GeneralRe: Doesn't work with toolstripcontainer (workaround found) Pin
Rainer Schuster21-Nov-06 2:17
Rainer Schuster21-Nov-06 2:17 
GeneralHelp ,Can this DockPane use LayoutMdi to arrange the titles Pin
shengcheng_jin9-Nov-06 16:16
shengcheng_jin9-Nov-06 16:16 
GeneralSelect tab DockState.DockLeft Pin
[Neno]7-Nov-06 9:12
[Neno]7-Nov-06 9:12 
QuestionProblem when showing Icon on Document Tab Pin
Sirodom5-Nov-06 15:15
Sirodom5-Nov-06 15:15 
AnswerCannot reproduce the error.... Pin
Danilo Corallo30-Dec-06 7:24
Danilo Corallo30-Dec-06 7:24 
QuestionAdd a button Pin
softwarejaeger4-Nov-06 0:17
softwarejaeger4-Nov-06 0:17 
Generalmoving and resizing Pin
t3j02-Nov-06 15:32
t3j02-Nov-06 15:32 
GeneralPossible to switch over different styles Pin
merlin.AT31-Oct-06 22:17
merlin.AT31-Oct-06 22:17 
GeneralResizing window generates error Pin
DaCodez25-Oct-06 6:36
DaCodez25-Oct-06 6:36 
GeneralLicensing Pin
Pierre M.5-Oct-06 6:45
Pierre M.5-Oct-06 6:45 
GeneralRe: Licensing Pin
Danilo Corallo6-Oct-06 6:12
Danilo Corallo6-Oct-06 6:12 
GeneralLoadExtenderBitmap Problem Pin
[Neno]30-Sep-06 0:04
[Neno]30-Sep-06 0:04 
GeneralRe: LoadExtenderBitmap Problem Pin
[Neno]3-Oct-06 8:44
[Neno]3-Oct-06 8:44 
QuestionHow to Change font of Tab Pin
vinodonly17-Sep-06 5:03
vinodonly17-Sep-06 5:03 
AnswerRe: How to Change font of Tab Pin
Danilo Corallo17-Oct-06 4:13
Danilo Corallo17-Oct-06 4:13 
GeneralAutoHideStrip Colors Pin
Laurent Muller5-Sep-06 20:52
professionalLaurent Muller5-Sep-06 20:52 
GeneralRe: AutoHideStrip Colors Pin
Danilo Corallo6-Sep-06 5:04
Danilo Corallo6-Sep-06 5:04 

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.