Visual Basic Window/Form Routines
Manifests: Make the VB IDE use Windows XP Styles
Posted:   Tuesday March 04, 2003
Updated:   Monday December 26, 2011
Applies to:   VB5, VB6
Developed with:   VB6, Windows XP
OS restrictions:   None
Author:   msnews groups


Shell_NotifyIcon: Animate the System Tray Icon
Pure VB: Cue Banners for the XP Impaired
SendMessage: Add Balloon Tips to a Combo Edit Box
SendMessage: Add Balloon Tips to a Text Box
Shell_NotifyIcon: Display Systray Balloon Tips
Manifests: Make the VB IDE use Windows XP Styles
Shell_NotifyIcon: Add Icon to Windows System Tray
Shell_NotifyIcon: Respond to Systray Icon/Menu Interaction
Shell_NotifyIcon: Respond to Systray Icon/Menu Interaction in a MDI App

SendMessage: Use Cue Banners to Prompt Users
Shell_NotifyIcon: Respond to Systray Balloon Tip Clicks
FlashWindowEx: Extended Window Notification (Flashing) Options
FlashWindow: Timing Window Notifications using SetTimer
FlashWindow: Timing Window Notifications using VB's Timer Control

Shell_NotifyIcon: Windows Systray NOTIFYICONDATA Overview


I often get asked how I create demo forms that have the XP style, as shown on pages generated over the past 18 months or so. My answer is the same -- I use Windows XP right out of the box, but with the silver theme applied and the titlebar font size reduced a tad. Nothing custom or special.

In the IDE, the forms and controls all have the pre-XP style; its really only the form border and titlebar that inherits the XP style automatically when running under XP. But it is possible to force the IDE to use controls in the Windows XP style (under XP of course), with a couple of caveats:

  • the style applies only to the IDE, including the IDE's dialogs. Apps compiled with XP style controls still appear as normal VB controls when run as the exe, unless the manifest file is provided for the app itself (see comments below).
  • the style can not be applied to the VB6 common controls. The VB6 Common Controls OCX does not utilize comctl32.dll, and thus the controls contained in that library will never take on the XP styles. The listview and treeview in the illustration are from the VB5 common controls, which uses comctl32.dll.
  • controls placed in frames may not take on the XP style. This particularly appears to apply to option buttons, which appear black. See the fix in the Comments section.
  • the manifest does not provide for XP-style menus.

The technique for doing this is simple. As anyone who has perused the MSDN or hung around the newsgroups knows, XP styles can be applied to a VB application through the inclusion of a XML manifest file with the application.  The format for naming the manifest is {exename}.{exe}.manifest. For example, if the application exe was called 'myapp.exe', the manifest would be 'myapp.exe.manifest'. When this manifest file is placed in the same directory as the application, the app will assume the XP styles (subject to the caveats above).

This same technique can be applied to the IDE itself. Create the manifest file using Notepad, and name it vb6.exe.manifest. Place it in the Visual Studio (or Visual Basic) folder containing vb6.exe and start VB. That's all it takes.

The illustration shows the standard controls in both the standard VB style, and the XP style after adding the vb6.exe.manifest file to the vb6.exe folder. If you want to remove the XP style effect permanently, simply delete the manifest file.

Note: Michael Feld wrote to let me know about a problem using the manifest with vb6.exe, specifically concerning the colour palettes in the property window. I could reproduce the problem; the System colours pane appears fine, but the Palette pane appears empty with no colours shown. Clicking in the palette area will select a colour, however.

The information in this article is provided more as a "FYI" than a "do this" recommendation to give designers a means to determine how a control might appear if they provided a manifest with the application exe. 

Note: The copy code button will automatically insert a VBnet copyright statement and a blank line into the copied text, as per other examples on the site. When creating the manifest file do NOT include this copyright statement in the final manifest file or an error starting VB will occur. The first line in the manifest file must begin with <?xml version=.

 Manifest Text
Using Notepad. add the following text to a new file and name the file vb6.exe.manifest. Save to the same folder containing VB6.exe. Because Notepad likes to append .txt to all files it creates, regardless if you've provided another extension, be sure to check the filename and remove any appended .txt from the name.

' Copyright 1996-2011 VBnet/Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
' Distribution: You can freely use this code in your own
'               applications, but you may not reproduce 
'               or publish this code on any web site,
'               online service, or distribute as source 
'               on any media without express permission.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<description>VBnet Manifest for VB6 IDE</description>
To have your final exe display controls using the XP styles follow these tips:
  • create a manifest as above, naming it myapp.exe.manifest (where myapp is the name of your application)
  • install it into the same folder as the exe
  • declare the InitCommonControls() API in a bas module within the project, and call this from the Initialize event, not the Load event, in each form. The Initialize event fires when the code is loaded but before the graphical interface is created. Load is called when the interface is created, which for the XP styles to be applied is too late into the application. Calling inappropriately (or not at all) will most likely result in a hung app with no interface presented.
  • controls (such as option buttons and check boxes) within a Frame control will loose the XP style and appear as black boxes. The problem is that to draw the XP styles the container must provide a device context handle (hDc) with which to perform the GDI functions.  Since frames don't provide an hDc the result is an unpainted (black) controls.  A tip I received from Quintin Prinsloo to overcome this problem is to place the controls inside a picture box - which has a hDc - and then place the picture box into the frame. By setting the border style to none the controls paint correctly without the appearance of the extra picture box.


PayPal Link
Make payments with PayPal - it's fast, free and secure!


Copyright 1996-2011 VBnet and Randy Birch. All Rights Reserved.
Terms of Use  |  Your Privacy


Hit Counter