This topic describes the first steps necessary for building an application with Skybound VisualStyles.
The key concepts of this topic are:
If you are using Microsoft Visual Studio .NET®, you will need to add a reference to Skybound.VisualStyles.dll to your project before using it.
Other visual IDEs may have different ways of referencing assemblies. You should consult the product documentation included with the IDE for instructions.
This section describes the steps necessary to enable VisualStyles in your application.
VisualStyles is enabled by adding one line of code to your application's Main() method. In Visual Studio 2002 and 2003, this method is created in your startup form by default. In Visual Studio 2005, this method is in Program.cs by default.
[C#]
using (Skybound.VisualStyles.VisualStyleContext.Create()) Application.Run(new Form1())
To use VisualStyles, you must handle the application startup event.
From the Project menu, click Properties, then the View Application Events button. Add the following code to that class:
[VB.NET 2.0]
Shared VSContext As Skybound.VisualStyles.VisualStyleContext Public Sub HandleStartup(ByVal sender As Object, ByVal e As ApplicationServices.StartupEventArgs) _ Handles Me.Startup VSContext = Skybound.VisualStyles.VisualStyleContext.Create End Sub
To use VisualStyles, your application must start from Sub Main.
By default, all Visual Basic applications start using a Startup Form. To switch your application to Sub Main, follow these 3 steps:
[VB.NET 1.x]
Shared VSContext As Skybound.VisualStyles.VisualStyleContext Public Shared Sub Main() VSContext = Skybound.VisualStyles.VisualStyleContext.Create Application.Run(New Form1) End Sub
If your application is already has a Sub Main, just add the green lines in the code above to the existing class.
First, add the VisualStyleFilter component to the toolbox. In Visual Studio .NET, this is done by:
Other visual IDEs may have different ways of adding custom components to the toolbox. You should consult the product documentation included with the IDE for instructions.
Once a VisualStyleFilter component has been added to a form designer, all controls receive a new property called VisualStyleEnhanced. Set the value of this property to Yes to force a control to be enhanced, No to prevent it from being enhanced, or Default to cause it to use the application-wide default setting
NOTE: The application-wide default setting is set with the SetEnhancedDefault static (Shared in Visual Basic) method.
It is not necessary to create a VisualStyleFilter component unless you are using a forms designer. At runtime, the VisualStyleFilter.Global object is available at all times for the same purpose.
This example prevents a control called textBox1 from being enhanced:
[C#]
VisualStyleFilter.Global.SetVisualStyleEnhanced(textBox1, VisualStyleEnhanced.No);
[Visual Basic]
VisualStyleFilter.Global.SetVisualStyleEnhanced(textBox1, VisualStyleEnhanced.No)