Windows XP visual styles in C#?

This is a discussion on Windows XP visual styles in C#? within the C# Programming forums, part of the General Programming Boards category; How do I go about enabling Windows XP visual styles when using C#? Is there a simple solution to this? ...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    20

    Windows XP visual styles in C#?

    How do I go about enabling Windows XP visual styles when using C#?

    Is there a simple solution to this?

    Regards

  2. #2
    Registered User
    Join Date
    Jan 2003
    Posts
    648
    You bet there's a way. The simplest solution is:

    1. Set the FlatStyle property of all your controls to System.
    2. Put this into a file called <application name>.exe.manifest
    (Where <application name> is your app's file name.)
    3. Put the file into the same directory as your .exe file.
    Code:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
    	<assemblyIdentity
    		version="1.0.0.0"
    		processorArchitecture="x86"
    		name="Application"
    		type="win32" />
    	<description>
    		An application that usesthe themed ctls.
    	</description>
    	<dependency>
    		<dependentAssembly>
    			<assemblyIdentity
    				type="win32"
    				name="Microsoft.Windows.Common-Controls"
    				version="6.0.0.0"
    				publicKeyToken="6595b64144ccf1df"
    				language="*"
    				processorArchitecture="x86" />
    		</dependentAssembly>
    	</dependency>
    </assembly>
    There is a way to merge this file into your .exe so you don't have two different files but you asked for a simple way. Merging is a bit tricky and you need to use a different manifest file I think. To find out how, just do a simple search on yahoo or google.

    BTW, this method I described also works for VB6 .exe's.
    Last edited by Speedy5; 03-22-2003 at 08:37 AM.

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    20
    Thanks for that.

    Can you also explain how to add the manifest as a resource? I've tried following the MSDN examples, but I get error messages whenever I run the app without the manifest present. They work fine with the manifest.

    Also, do you know why you need to check at load time for the presence of Window XP? I would have that that the app would default to the old style anyway.

    Cheers

  4. #4
    Registered User
    Join Date
    Nov 2001
    Posts
    20
    Forget that - I've sussed it

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM
  2. Visual C++ .NET 2003 and XP Style
    By kuphryn in forum Windows Programming
    Replies: 1
    Last Post: 10-07-2003, 11:08 AM
  3. Windows XP visual themes and style changing
    By bennyandthejets in forum Windows Programming
    Replies: 15
    Last Post: 10-03-2003, 10:49 AM
  4. Windows XP visual styles
    By larry in forum Windows Programming
    Replies: 9
    Last Post: 08-09-2003, 02:09 PM
  5. odd errors from msvc std library files
    By blight2c in forum C++ Programming
    Replies: 6
    Last Post: 04-30-2002, 12:06 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21