How to create a Windows XP Visual Styles App in VB.net 
Author Message
 How to create a Windows XP Visual Styles App in VB.net

Hi,

    Anyone know how to using vb.net to create application with XP visual
styles?

Regards,
Eric Wong



Wed, 07 Apr 2004 12:58:26 GMT  
 How to create a Windows XP Visual Styles App in VB.net
There will be a whitepaper posted soon to MSDN Online
(http://msdn.microsoft.com) covering this topic in depth. Similarly, there
is a talk planned for the upcoming PDC covering this issue.

Be aware that the steps outlined below only apply to applications running on
the Windows XP operating system.

Briefly, you can think of a form as being composed of two distinct parts: a
client area and a non-client area. All applications running on the Windows
XP operating system have a non-client area, which includes the window frame,
title bar, and non-client scrollbars. A visual style is applied to the
non-client area by default, so that even without making the changes
described below, you will see an updated title bar and scroll bars on
Windows Forms running on Windows XP. In the next steps, we will describe how
to make changes to the client area.

The appearance of the non-client area is specified by the visual style that
is currently applied. The visual style is the modifiable appearance of the
user interface of an application or operating system. As already mentioned,
the form's scrollbars and title bar will change immediately when run on
Windows XP. Some Windows Forms controls will assume their new guise as soon
as the application is bound to version 6.0 of Comctl32.dll.
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 the
Comctl32.dll, version 6.0. (The sample manifest file below can be used, with
a few tweaks that we will cover) to bind any application created with Visual
Studio .NET to the Comctl32.dll.)

       Add this resource (the manifest) to your executable file and
rebuild it.

Procedure:

  1.. Create a Windows Application project.
  2.. Add controls.
       A few controls (Label controls, LinkLabel control, DomainUpDown
control, NumericUpDown control, CheckedListBox control) will not pick up XP
visual styles. This just means they will look the same whether we go through
this procedure or not.

       Most controls will pick up visual styles when we bind the
application manifest (details below).

       Finally, the controls that derive from the
System.Windows.Forms.ButtonBase class (the Button, RadioButton, and CheckBox
controls) have a property that indicates how the controls should be drawn.
This property, FlatStyle, needs to be set to System for these controls to be
drawn appropriately.

  3.. Set the Button, RadioButton, and CheckBox control's FlatStyle property
to System, if you have any on your Windows Form.
  4.. From the Build menu, choose Build to build your solution.
  5.. From the File menu, choose Save All to save your work.

Okay, now that our form is designed, let's create the manifest file.

1.      In Solution Explorer, right-click the project and choose Add then
New Item.

The Add New Item dialog box opens.

2.        In the left-hand pane (Categories), click Local Project Items. On
the right-hand pane (Templates), click Text File. In the name box, name the
file in the following manner: <Executable Name>.exe.manifest. Thus, if your
application is called MyXPApp, you would name the XML file
MyXPApp.exe.manifest.

Click the Open button to create the XML file and close the dialog box.

The empty text file you added opens in the text editor.

3.      Add the following XML to the text file:

Note   In the XML sample below, be sure to replace <Executable Name> with
the actual name of your executable file, just as you did in step 2.

<?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="Microsoft.Winweb.<Executable Name>"

   type="win32"

/>

<description>.NET control deployment tool</description>

<dependency>

   <dependentAssembly>

     <assemblyIdentity

       type="win32"

       name="Microsoft.Windows.Common-Controls"

       version="6.0.0.0"

       processorArchitecture="X86"

       publicKeyToken="6595b64144ccf1df"

       language="*"

     />

   </dependentAssembly>

</dependency>

</assembly>

Tip   If the < and > symbols are replaced with &lt; and &gt; when you paste,
remove the pasted text, and then re-paste the schema by right-clicking the
design surface and selecting Paste as HTML from the shortcut menu.

4.      From the Build menu, choose Build to build your solution.

5.      From the File menu, choose Save All to save the XML file.

Next, move the manifest to the executable file's directory.

1.      In Windows Explorer, navigate to the directory where the Visual
Studio solution is saved.

In this directory, you should see the manifest file we created in the
section above (this is the file we named <Executable Name>.exe.manifest).

2.      Click the manifest to select it and, from the Edit menu, choose
Copy.

3.      Now, open the obj directory and then the debug or retail directory
(depending on the build option you set in the development environment). This
will be the directory containing your executable file (The executable file's
name will be in the form of ProjectName.exe).

4.      From the Edit menu, choose Paste to copy the manifest file into this
directory.

Finally, add the manifest to the executable file.

1.      In the Visual Studio development environment, on the File menu,
point to Open, then click File.

2.      Navigate to the directory containing this Visual Studio solution.

3.      Open the obj directory and then the debug or retail directory
(depending on the build option you set in the development environment).

4.      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.

5.      Right-click the executable file and choose Add Resource.

6.      In the Add Resource dialog box, click the Import button.

7.      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.

8.      Double-click the manifest file.

The Custom Resource Type dialog box opens.

9.      In the Resource Type box, type RT_MANIFEST and click OK.

10.  In the Properties window, set the ID property to 1.

11.  From the File menu, choose Save All to save the changes you have made.

When you run your application, the controls on your Windows Form appear in
the Windows XP visual style.

Please feel free to respond with any other issues or concerns you have.

Seth Grossman

Microsoft Corp.

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. ? 2001 Microsoft Corporation. All rights
reserved.


Quote:
> Hi,

>     Anyone know how to using vb.net to create application with XP visual
> styles?

> Regards,
> Eric Wong



Wed, 07 Apr 2004 07:22:53 GMT  
 How to create a Windows XP Visual Styles App in VB.net
Hello,

I've made it work by putting the manifest below in the same folder as the
app.

However, I can't figure out how to make this into a resource that gets
compiled into the app, which makes it kinda useless IMHO. Anybody?

-- Charles Wiltgen

<?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>


Quote:
> Hi,

>     Anyone know how to using vb.net to create application with XP visual
> styles?

> Regards,
> Eric Wong



Wed, 07 Apr 2004 07:25:07 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. VB.Net 2003 XP Visual Styles

2. ANN: TaskBar.NET (Windows XP style Common Task Folder)

3. New Windows XP Style ExplorerBar for .NET

4. How to create XP Style forms with .Net

5. Windows XP visual style - Add Resource does not work

6. Windows XP Visual Styles

7. Windows XP Visual Styles?

8. Using Visual Styles in Windows XP

9. Emulation XP Style from VB.NET

10. VB.net or C# with XP style Control

11. VB Projects and Windows XP Style

12. Windows XP style controls in VB

 

 
Powered by phpBB® Forum Software