5,530,111 members and growing! (16,160 online)
Email Password   helpLost your password?
Languages » VB.NET » General     Intermediate

.Net Win Forms Themes

By Chandra Hundigam

Creating Custom theme/skins in .net require merely a few lines of code
VBWindows, .NET, .NET 1.1, Win2K, WinXPVS.NET2003, Visual Studio, Dev

Posted: 28 Jun 2004
Updated: 8 Jul 2004
Views: 57,410
Bookmarked: 19 times
Announcements



Search    
Advanced Search
Sitemap
15 votes for this Article.
Popularity: 3.00 Rating: 2.55 out of 5
4 votes, 26.7%
1
5 votes, 33.3%
2
1 vote, 6.7%
3
2 votes, 13.3%
4
3 votes, 20.0%
5
Note: This is an unedited contribution. If this article is inappropriate, needs attention or copies someone else's work without reference then please Report This Article

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

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

About the Author

Chandra Hundigam


Chandra Hundigam has Master degree in Computer Application, Microsoft Certified Professional and Software Architect. He's significantly involved in enterprise application development and distributed object oriented system development using Microsoft .Net, Sun Java/J2EE technology to serve global giants in the Media, Finance, Mortgage and Software Industries.Presently working as Software Consultant for a US-based company.His areas of interests are in emerging Technologies.
Occupation: Architect
Location: United States United States

Other popular VB.NET articles:

  • Writing Your Own GPS Applications: Part I
    What is it that GPS applications need to be good enough to use for in-car navigation? Also, how does the process of interpreting GPS data actually work? In this two-part series, I will cover both topics and give you the skills you need to write a commercial-grade GPS application.
  • Using PropertyGrid Part-I
    Explains about PropertyGrid and how to use, with detailed examples
  • Web Service Dispatcher
    A simple web service to manage other web services
  • A VS2005-like Interface
    Apply a theme that resembles VS2005 to the DockPanel Suite, using an Extender class.

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 1 of 1 (Total in Forum: 1) (Refresh)FirstPrevNext
Subject  Author Date 
Generalupdated articlememberChandra Hundigam7:08 9 Jul '04  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 8 Jul 2004
Editor:
Copyright 2004 by Chandra Hundigam
Everything else Copyright © CodeProject, 1999-2008
Web18 | Advertise on the Code Project