windows xp controls appearance

ramone

Freshman
Joined
Sep 29, 2005
Messages
26
hello

how can i make my controls look like winxp controls? for example, winxp tabs and buttons have rounded corners and get a nice orange line on mouse hover, controls in vb.net have the classic style

thank you=)
 
There are a few ways. this is how I do it

in the main sub do this

Public Shared Sub main()
Application.EnableVisualStyles()
Application.DoEvents()
Application.Run(New frmMain)
End Sub

and in the properties section for FlatStyle make it System. Not all the controls have this property. And this will only work on a machine that has XP. If you have 2000 or 98 it will not show what you want. You would have to goto a 3rd party vendor and get controls they have created
 
To get XP style for things like progress bars, group boxes, and tab controls (the stuff techmanbd mentioned doens't have the FlatStyle property), you'll need a manifest file. To use one of these createa text file called [name of your exe].exe.manifest. Inside that manifest file put the following:
Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<!-- For this file to work the version must match the executable version
     EXACTLY as well as the exectuable name.
     This gives slick looking mostly XP styles to the GUI.  -->
<assemblyIdentity
   version="1.0.0.0"
   processorArchitecture="X86"
   name="[NAME OF YOUR EXE HERE]"
   type="win32" />

<dependency>
<dependentAssembly>
<assemblyIdentity
   type="win32"
   name="Microsoft.Windows.Common-Controls"
   version="6.0.0.0"
   processorArchitecture="X86"
   publicKeyToken="6595b64144ccf1df"
   language="*" />

</dependentAssembly>
</dependency>
</assembly>

Be sure to change the version number and name in the assebmlyIdentity tag to match the version number and name of the GUI exe.

This will give you cool mouse overs on your tab control and a few other things. It is also worth noting that the controls are all going to look sweet in the next VS.

Edit:
I should have looked before I posted, but here is an extremely informative thread on this subject.
 
first of all thanks for your help

i have two questions for your solutions. first, where to save the manifest file or how to link it to my project?. second, i don't have a main sub for the techmanbd's solution

sorry but i'm not experienced with vb.net
thanks again =D
 
ramone said:
First, where to save the manifest file or how to link it to my project?
Sorry, I forgot to tell you. Put it in the same directory as your executable. I ussually add it to my project and change the build action to 'none' to make sure that I don't forget about it and for easier modification. You'll have to copy it to your buld directory when you upgrade the version. It just sits in the same folder as the exe.

Also, remember that this will only enable visual styles that are native to the machine. That means that if you are on a Win2000 machine, the controls will be in the Win2000 style.
 
I recommend you set the build action to "Content". This means that the file will be included when the software is distributed, for example, when you create a deployment project.

As far as the Sub Main goes, just slap it into the code of the main form.
 
I thought that if you added the manifest file, you didn't need to do the enablevisualstyles() in code anymore??
 
What's the licensing for the skybound control? It looks nice but it says that it costs $150. It also says free download...what's the deal?

Wile said:
I thought that if you added the manifest file, you didn't need to do the enablevisualstyles() in code anymore??
I've always just used the manifest file but I also had to set some stuff FlatStyle properties to system (like buttons) to make it all look good. I have never called enablevisualstyles() to get these effects, so it that seems to be just a different (and more buggy apparently) way of doing things.

marble_eater said:
I recommend you set the build action to "Content".
Pro strat, man. Thanks for the advice. I will start using that immediately.
 
I have never had a problem with EnableVisualStyles and exceptions, and to resolve any confusion: you only need either a manifest or EnableVisualStyles(), not both.

Here is a third solution involving manifests: The manifest can be embedded within the exe.
MSDN said:
To add the manifest as a resource

In the Visual Studio development environment, on the File menu, point to Open, then click File.
Navigate to the directory containing this Visual Studio solution. This is the directory you saved it in during Step 1 of the "Create the Project" section.
Open the obj directory and then the Debug or Release directory (depending on the build option you set in the development environment).
Locate the executable file (it will be in the form of ProjectName.exe) and double-click it to open it with the Visual Studio environment.
Right-click the executable file in the designer and choose Add Resource.
In the Add Resource dialog box, click the Import button.
Navigate to the manifest file you created, which should be located in the same directory as your solution.
Note Be sure that the Files Of Type field in the dialog box is set to All Files (*.*) so that you can see the manifest file in the file picker.
Double-click the manifest file.
The Custom Resource Type dialog box opens.

In the Resource Type box, type RT_MANIFEST and click OK.
In the Properties window, set the ID property to 1.
From the File menu, choose Save All to save the changes you have made.
Beware: Opening and saving a .EXE with Visual Studio will mess up any ARGB icons (you lose the alpha data and instead get a jaggy masked image). I am not sure whether this affects ARGB PNGs. I don't know if this is a bug or because the .Net image editor doesn't support 32-bit ARGB images, but for this reason I prefer EnableVisualStyles() over embedding a manifest. I'm big on pretty icons.
 
The Skybound control is a free download, free to use. The $150 is for the source code.

The 'bugs' that it fixes are listed at:

http://www.skybound.ca/developer/visualstyles/default.aspx

The license is available at:

http://www.skybound.ca/developer/visualstyles/docs/license.html

An excerpt from the website states:

VisualStyles is a free product, and you are welcome to redistribute it with your applications—both commercial and not-for-profit—free of charge (in accordance with the terms of our Free Binary License).
 
Thanks. That was the exact information I needed and I was having a hard time finding it for some reason.
 
Back
Top