How to enable XP styled buttons?

EFileTahi-A

Contributor
Joined
Aug 8, 2004
Messages
623
Location
Portugal / Barreiro
I truly don't understand why .NET "so-used" controls like a button don't have included on its "appearance" options the possibility to turn them into WinXP styled buttons.

How can I make them look like WinXP buttons? I searched the web and a found some controls to do this, some are freeware others are not, still, I would like to know if there is a way doing this, skiping the need of instaling addional controls...
 
- THREAD RE-OPENED -

Ok, I have this prob, Application.EnableVisualStyles cease to work for some good reason, all my controls no longer have the WinXP look. I truly don't understand why, I made a new project to test the EnableVisualsStyles and it works fine, but in some other project of mine, (the one in which I first tryed the VisualStyles) stopped working.

The Applcation.EnableVisualStyles Is emidiately behind the Run Application Method as it was always. Yet I confirmed all the controls (buttons) FlatStyle if they were set to "System".

Any ideias?

I can't post any code since I'm at home at the momment, yet, what kind of code woud it to be required (if actually necessary)?
 
After Application.EnableVisualStyles put Application.doevents

It seems when you start increasing controls it stops working. But put the doevents in between the Application.EnableVisualStyles and Run and it works
 
If that doesn't work, you can always use this alternative:

Set each control with a FlatStyle property to FlatStyle.System

Create a manifest file to bind your app to comctl6. The sample manifest file below can be used to bind any app (managed or unmanaged) to comctl6. Just copy it to the location of the .exe and rename it to <app name>.exe.manifest.

You must then add a Win32 resource to your application. This is accomplished by first opening up the *.exe.

1. Open your exe in VS (file -> open file)
2. Right click on it and select add resource
3. Click "Import..." from the dialog
4. Select your manifest file
5. In the "Resource Type" field, enter "RT_MANIFEST"
6. In the property grid, change the resource ID from "101" to "1".
7. Save the exe.
8. Make sure the manifest is keep at the same directory level as the executable. (In this How-To it is placed in the bin directory of the solution)
 
The Application.DoEvents seems to have no effect on the problem :(, so am going to try Decrypt's method. Unfortunately I don't understand part of what he wrote: "Create a manifest file to bind your app to comctl6." What is / how can I do this?
 
Take a look at these articles, they also explain how to use a manifest file (but use a 32bits versil of the common control library ;) )

http://www.codeproject.com/vb/net/XPStyleB.asp
http://www.codeproject.com/csharp/XPStyleUI.asp

Doesnt matter if it is VB or C#, manifest works the same for all .net languages (they are handled by the framework, not the application). This is also why working with a manifest file has better results than using enablevisualstyles. The enablevisualstyles starts working after the application is created and might be to late (must be the first statement in the main method to have any chance) to do its 'magic'. The manifest file is loaded by the .net framework before loading the application, making sure all the 'magic' is done in time ;).
 
yeah the application.enablevisualstyles causes a lot of problems with me when I do a selected index change on a listbox.
 
Wile said:
Take a look at these articles, they also explain how to use a manifest file (but use a 32bits versil of the common control library ;) )

http://www.codeproject.com/vb/net/XPStyleB.asp
http://www.codeproject.com/csharp/XPStyleUI.asp

Doesnt matter if it is VB or C#, manifest works the same for all .net languages (they are handled by the framework, not the application). This is also why working with a manifest file has better results than using enablevisualstyles. The enablevisualstyles starts working after the application is created and might be to late (must be the first statement in the main method to have any chance) to do its 'magic'. The manifest file is loaded by the .net framework before loading the application, making sure all the 'magic' is done in time ;).

Thank you very much wile! It is working once more! :D
 
I suggest you go to www.skybound.ca and download VisualStyles, which is a free component that overcomes pretty much all of the limitations of Visual Studio when it come to visual styles. There is no need for manifests, no need to change the FlatStyle or anything. It all just works with virtually no effort. Add the component to each form and your done.
 
I second jmcilhinney's suggestion - the Skybound control is far superior to Microsoft's "broken" implementation of XP Styles.

B.
 
Back
Top