Adding support for XP Themes to VB6 Apps

XP has some nice visuals and VB programmers definitely want in on XP Themes.  Unfortunately Microsoft DOES NOT support VB6 applications that enable themes.  Q309366 INFO: Visual Basic 6.0 Does Not Support Windows XP Themes or Visual Styles.


If you want to learn how to enable visual styles for your VB6 app read the article, it’ll show you how.  There is one step in the Q article that I’d like to clarify.  In the more info section, the first step says to call InitCommonControls and add a manifest file.  If you read the docs for InitCommonControls you’ll see it’s obsolete and you need to use InitCommonControlsEx, you’ll also see that if you have a manifest file you will NOT need to call InitCommonControls.


Another problem that may arise when running VB6 applications that support themes is that you may get an access violation when closing the application or forms within your application.  I’ve seen this where the app works fine within the IDE but fails with the AV when run from the compiled executable.  Typically this is a module unload issue, a given module your application is unloaded even though there are other resources in your application still wanting to use the module.  The only cases I’ve seen involve comctl32.dll.  You can prevent this error by explicitly loading the dll in the query unload event of the form causing the problem:



Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long


Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)

    LoadLibrary ("comctl32.dll")

End Sub

Comments (0)

Skip to main content