|
This post originated from an RSS feed registered with .NET Buzz
by Jon Box.
|
Original Post: Windows XP: Enabling Visual Styles
Feed Title: Jon Box's Weblog
Feed URL: http://radio-weblogs.com/0126569/rss.xml
Feed Description: This is a log of my findings and amusements with .NET. I also present information on my presentations and others that I see.
|
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Jon Box
Latest Posts From Jon Box's Weblog
|
|
In the near future, you will hear more about Visual Styles, a cool UI feature in Windows XP. This feature makes your WinForm applications look professional by doing just a few steps: 1) enable VisualStyles via various mechanisms and 2) set controls with a FlatStyle property to "System".
Enable Visual Styles In v1.1 of the .NET Framework, you can call EnableVisualStyles like the following:
Public Shared Sub Main() Application.EnableVisualStyles() Application.DoEvents() Application.Run(New Form1) End Sub
This usage has issues as some of screens in an app that I did generated strange,sporadic runtime errors. When I commented the EnableVisualStyles line out, it worked fine. Some folks also prescribed to add a DoEvents before this as done in the sample. See http://www.syncfusion.com/faq/winforms/search/1046.asp for other thoughts and an example in C#.
Due to unsolved strange errors continuing, I finally went away from this and am using a manifest file. Its so easy because you just take the below text and put into a file with a name of YourApp.EXE.Manifest in your execution directory. That is all there is to it.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <description>tester</description> <dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="X86" publicKeyToken="6595b64144ccf1df" language="*" /> </dependentAssembly> </dependency> </assembly>
Setting the Controls Also, dont forget to change all controls that have a FlatStyle property to the System value. If you do this through the property window, it generates the following: Me.LabelGreeting.FlatStyle = System.Windows.Forms.FlatStyle.System
Also, check out Mr. Hanselman's thoughts on this.
Read: Windows XP: Enabling Visual Styles
|