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. It’s 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, don’t 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.
10:48:14 AM
|