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

.Net Win Forms Themes

Rate me:
Please Sign up or sign in to vote.
3.00/5 (24 votes)
8 Jul 20042 min read 260.7K   11K   57   8
Creating Custom theme/skins in .net require merely a few lines of code

Introduction

The article focuses on creating themes in VB.net Win Forms. As we know many times in much application we see different style of forms and its shape, for example windows media player where you change the form style or in another words its skin.

And many times in GUI development we need something different style and shape for the win forms.  A theme is basically changing the appearance of the form and its representation. In some cases themes are also called as skins. In .net it’s pretty simple to implement non-rectangle forms.

In order to implement this concept I have used pretty simple example where you can see that when you select a theme from the combo box it automatically changes complete presentation.

The sample with this article is self explanatory and simple. In order to implement non-rectangular forms we need to do following steps.

Step1: Create a .jpg file that will be used to set the forms background

Step2:  Create a Windows Application project and set properties to use the .jpg as the
            background of the form and get rid of the title bar.

Step3: Using GraphicsPath Object change the forms shape

Step4: Add the code for moving the form and closing it.

In this sample I created a class called Theme. And Theme1, Theme2 are derived classes of Theme. Each does its own implementation of Theme. When user selects the theme from combo box in the form, The Form appearance changes as theme is changed.

Below Figures shows the sample application functionality.

Fig [1] WinForm before selecting Theme

Winform befor selecting Theme

Fig [2] WinForm after selecting Theme1
 

winform after selecting Theme1

Fig [3] WinForm after selecting Theme2

Winforms after selecting Theme2

 

In the sample Application class 'Theme" is the base class which has two properties

1.BackGroundImage: Which holds the background image for the form

2.TransperncyColor: Which holds the transperancy color for the form

(one can extend the class with more properties if needed)

and a MustOverride method called

1.SetTheme(ByRef frmObj As Form) : The derived class must override this method and do implementation of theme. In the sample application, there are two derived classes called "Theme1" and "Theme2". Each does different implementation of theme.

Class "Theme1" concentrates on displaying form as shown in figure1 above<o:p>

And Class "Theme2" concentrates on displaying form as shown in figure2 above.

Code beneth the SetTheme(ByRef frmObj As Form) method of class Theme1 and Theme2 are pretty self explanatory.

 

 

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Architect
United States United States
Chandra Hundigam-Venkat has Master degree in Computer Application, Microsoft Certified Professional and Cloud & Software Architect. Significantly involved in Cloud solutions, Cloud native application, Cloud migration, Enterprise application development distributed object oriented system development. Started computer career at the early age of eighteen as an intern in computer labs and had the opportunity to work with various USA fortune 500 companies in various technology and leadership roles.


Comments and Discussions

 
QuestionNice, but mouse handling is a little bit bad Pin
Axel Steiner2-Aug-15 14:26
Axel Steiner2-Aug-15 14:26 
GeneralMy vote of 1 Pin
Rixterz1239-Jun-14 8:10
Rixterz1239-Jun-14 8:10 
QuestionC# thems Pin
dilan9125-Aug-12 23:27
dilan9125-Aug-12 23:27 
GeneralThis helped me create my custom theme! Thank you!!!! 5 stars! Pin
TheRomanian18-Apr-11 5:01
TheRomanian18-Apr-11 5:01 
This helped me create my custom theme!

Great article!

Thank you!
How old is the Orthodox Faith?
http://www.orthodoxphotos.com/history.shtml

If you are a Lutheran, your religion was founded by Martin Luther, an ex-monk of the Catholic Church, in the year 1517. If you belong to the Church of England, your religion was founded by King Henry VIII in the year 1534 because the Pope would not grant him a divorce with the right to re-marry. If you are a Presbyterian, your religion was founded by John Knox in Scotland in the year 1560. If you are a Congregationalist, your religion was originated by Robert Brown in Holland in 1582. If you are Protestant Episcopalian, your religion was an offshoot of the Church of England, founded by Samuel Senbury in the American colonies in the 17th century. If you are a Baptist, you owe the tenets of your religion to John Smyth, who launched it in Amsterdam in 1606. If you are of the Dutch Reformed Church, you recognize Michelis Jones as founder because he originated your religion in New York in 1628. If you are a Methodist, your religion was founded by John and Charles Wesley in England in 1774. If you are a Mormon (Latter Day Saints), Joseph Smith started your religion in Palmyra, New York, in 1829. If you worship with the Salvation Army, your sect began with William Booth in London in 1865. If you are Christian Scientist, you look to 1879 as the year in which your religion was born and to Mary Baker Eddy as its founder.

If you belong to one of the religious organizations known as "Church of the Nazarene, Pentecostal Gospel," "Holiness Church," or "Jehovah's Witnesses," your religion is one of the hundreds of new sects founded by men within the past hundred years.

If you are Roman Catholic, your church shared the same rich apostolic and doctrinal heritage as the Orthodox Church for the first thousand years of its history, since during the first millennium they were one and the same Church. Lamentably, in 1054, the Pope of Rome broke away from the other four Apostolic Patriarchates (which include Constantinople, Alexandria, Antioch and Jerusalem), by tampering with the Original Creed of the Church, and considering himself to be infallible. Thus your church is 1,000 years old.

If you are Orthodox Christian, your religion was founded in the year 33 by Jesus Christ, the Son of God. It has not changed since that time. Our church is now almost 2,000 years old. And it is for this reason, that Orthodoxy, the Church of the Apostles and the Fathers is considered the true "one Holy Catholic and Apostolic Church." This is the greatest legacy that we can pass on to the young people of the new millennium.

GeneralReply Pin
codertuhin2-Feb-09 5:52
codertuhin2-Feb-09 5:52 
GeneralRe: Reply Pin
minhhaitpro12-May-11 15:08
minhhaitpro12-May-11 15:08 
GeneralNice! Pin
cpparasite5-Dec-08 20:19
cpparasite5-Dec-08 20:19 
Generalupdated article Pin
Chandra Hundigam Venkat9-Jul-04 6:08
Chandra Hundigam Venkat9-Jul-04 6:08 

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.