Recently, I got some friends asking me about how can they add Windows XP visual style on their Visual Basic application.
Why can't you get the XP style look when you run or compile your Visual Basic application anyway? For your information, the Windows XP Visual Styles are provided by ComCtl32.dll version 6 or later. The ComCtl32 does not apply the latest styles to the client area of an application by default. So, in order to enable it, you need to ensure that your application is linked to the new ComCtl32.dll by calling the ComCtl's InitCommonControls API call. And then, you also need to provide a Manifest file which specifies that the new version of the control styles should be used.
To make this short. All you need to add to your code is this lines of codes on a module...
Private Type tagInitCommonControlsEx
lSize As Long
lICC As Long
Private Declare Function InitCommonControlsEx Lib "comctl32.dll" _
(iccex As tagInitCommonControlsEx) As Boolean
Private Const ICC_USEREX_CLASSES = &H200
Public Function InitCommonControlsVB() As Boolean
On Error Resume Next
Dim iccex As tagInitCommonControlsEx
.lSize = LenB(iccex)
.lICC = ICC_USEREX_CLASSES
InitCommonControlsVB = (Err.Number = 0)
On Error Goto 0
Public Sub Main()
' Call the function before other codes
' Start your application here:
Then add this text in a text file...
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<description>Your application description here
and rename the text file to 'yourexefilename.exe.manifest' and save it in the same folder with your exe file. Also make sure that your application Startup Object is Sub Main (check this in Project > [your app] Properties).
That's all. You can see your application is using XP Style after you compile it and run it outside Visual Basic. You can't see the changes if you run it using Visual Basic.
You can also get detail explanation on this at vbAccelerator. Enjoy!