The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Windows XP: Enabling Visual Styles

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Jon Box

Posts: 244
Nickname: jonbox
Registered: Dec, 2003

Jon Box is a .NET Developer and Regional Director.
Windows XP: Enabling Visual Styles Posted: Feb 5, 2004 9:04 AM
Reply to this message Reply

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

Advertisement

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.

 

Read: Windows XP: Enabling Visual Styles

Topic: Portable geek gym Previous Topic   Next Topic Topic: MVP Global Summit April 3-8

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use