Adam Caudill

Security Leader, Researcher, Developer, Writer, & Photographer

XP-Style Controls In Visual Basic 6

This post was imported from an old blog archive, and predates the creation of

This is a quick and dirty overview of how to get those ever so coveted XP controls in your application. There is a lot of detail I’m leaving out, but you should get the point, if you want more detail a google search or two should give you plenty of info.

Let’s get started….

First you need to make a manifest file, this is just a plain text file that tells Windows how to treat you program. Paste the following into Notepad and save it in the same folder that your program is in, with the name <appname>.exe.manifest (where <appname>.exe is the name of your program, i.e. the manifest for MyGame.exe would be MyGame.exe.manifest).

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
        type="win32" />
    <description>Your application description here</description>
                language="*" />

Now, you’re almost done already! The next step is to bind your program to ComCtl32.dll, if it doesn’t you won’t get the pretty controls. Paste the following code somewhere in your program and call it as soon as your program starts (i.e. in Sub Main), this will ensure that your program actually links to the ConCtl32.dll file before any controls are drawn.

Private Declare Function InitCommonControlsEx Lib "comctl32.dll" ( _
    iccex As tagInitCommonControlsEx _
    ) As Boolean

Private Type tagInitCommonControlsEx
    lngSize As Long
    lngICC As Long
End Type

Private Const ICC_USEREX_CLASSES = &H200

Public Function InitCommonControlsVB() As Boolean
Dim iccex As tagInitCommonControlsEx

    With iccex
        .lngSize = LenB(iccex)
    End With
    InitCommonControlsEx iccex
    InitCommonControlsVB = (Err.Number = 0)
End Function

And your done! Enjoy your new fancy controls :p (Note, some controls don’t draw right on there own, if you have a control that doesn’t look right, add a Picture box to your form and move the offending control onto the Picture Box.)

Adam Caudill