Link to home
Start Free TrialLog in
Avatar of LeeHenry
LeeHenry

asked on

Creating a XP style to my VB project?

I read on the microsoft web site that:

"If you want your application to use visual styles, you must add an application manifest (a file used during the build process to specify a certain resource) that indicates that Comctl32.dll version 6 should be used if it is available. Version 6 includes some new controls and new options for other controls, but the biggest difference is support for changing the appearance of controls in a window."

"Unlike earlier versions of Comctl32.dll, version 6 is not redistributable. The only way you can use version 6 of the dynamic-link library (DLL) is to use an operating system that contains it. Windows XP ships with both version 5 and version 6. By default, applications use the common controls defined in Comctl32.dll version 5 (user controls are defined in User32.dll). Comctl32.dll version 6 contains both the user controls and the common controls. By changing the .dll associated with these controls, you are able to apply Windows XP visual styles to them."

Thus, in order to use Windows XP visual styles in your Windows Forms application, you must:

Set each control that has a FlatStyle property to FlatStyle.System.
Create a manifest file to bind your application to Comctl32.dll, version 6.0. The sample manifest file below can be used to bind any application created with Visual Studio .NET to Comctl32.dll.
Add this resource (the manifest) to your executable file and rebuild it.

My Question is:

Can this only be done in .Net? I am using VB 6.0. Also, I am using Windows 2000, not XP. If I can do what is mentioned above, how is this done? If not, is there another alternative?

Avatar of GhOsTID
GhOsTID

I found 2 links that might help you:

http://www.freevbcode.com/ShowCode.Asp?ID=4734
http://www.vbaccelerator.com/home/VB/Code/Libraries/XP_Visual_Styles/Making_VB_Apply_Visual_Styles_at_Design_and_Debug_Time/article.asp

The first one automatically generates manifest files for you and the next one shows how to make your VB6 IDE look how it would in XP.

I really hope these help you somewhat.
Avatar of Ryan Chong
Some other resources that might useful:

http://www.domaindlx.com/e_morcillo/scripts/cod/tips/grpbtnxp.asp 

Skinnable Button Control with Many Styles
http://www.freevbcode.com/ShowCode.Asp?ID=5024

Live Weather Map (with Animated GIF and XP Button Controls)
http://www.freevbcode.com/ShowCode.Asp?ID=4453
First, this is the manifest file you need to use (copy and paste this into a text file and name it "applicationName.exe.manifest"):

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity type="win32" processorArchitecture="*" version="6.0.0.0" name="mash"/>
<description>Your Application Name</description>
<dependency>
   <dependentAssembly>
      <assemblyIdentity
           type="win32"
           name="Microsoft.Windows.Common-Controls" version="6.0.0.0"
           language="*"
           processorArchitecture="*"
         publicKeyToken="6595b64144ccf1df"
      />
   </dependentAssembly>
</dependency>
</assembly>

Now, put this into the option explicit of the startup form:
Private Declare Function InitCommonControls Lib "comctl32.dll" () As Long

Now, under the Form_Initialize sub:

Private Sub Form_Initialize()
InitCommonControls
End Sub

This will set all items that appear by default look like XP in Windows XP,
to get items like the toolbar, statusbar and tabstrip to look like XP,
you must use Microsoft Common Controls 5.0, not 6.0, 6.0 will not work
it uses a different dll
That will work for all features in Windows XP, but only Windows XP. I have an OCX file that can be added into the components panel that will give you a few of the more popular Windows XP styles in any Windows operating system, like command buttons, frames, option buttons, check boxes, even the form itself with close, min, max and restore buttons, I don't really recommend using it though, it can cause errors in some systems and requires the OCX file anytime the application is run or nothing will work, the manifest file mentioned above will work everytime on every Windows version, but will only show the XP styles in Windows XP.

If you would like the OCX let me know
Avatar of LeeHenry

ASKER

Thanks everyone for the advice!
Steveo225... can I get the OCX from you?

Thanks..
ASKER CERTIFIED SOLUTION
Avatar of steveo225
steveo225
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
One last  question.
My program is already created. And it has numerous forms. The ocx works fine, but I would have to replace each new button with the old buttons, and do the same for all the rest of the program. I wanted to just change the style of the VB project( like you would do in windows). There is no way of doing this using Windows 2000 correct... ?

Not that i know of, i spent numerous hours trying to do the same thing before I gave up, thats another reason I didn't reccommmend using the ocx, you have to replace all the controls, using the same name as the old controls will save you the time of redoing any code though.