Private Type DLLVERSIONINFO
cbSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
End Type
Private Declare Function GetThemeSysSize Lib "uxTheme" ( _
ByVal hTheme As Long, _
ByVal iSizeId As Long) As Long
Private Declare Function GetVersionExA Lib "kernel32" _
(lpVersionInformation As OSVERSIONINFO) As Integer
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type
Public Const VER_PLATFORM_WIN32s = 0 ' Win32s on Windows 3.1
Public Const VER_PLATFORM_WIN32_WINDOWS = 1 ' Windows 95, Windows 98, or Windows Me
Public Const VER_PLATFORM_WIN32_NT = 2 ' Windows NT, Windows 2000, Windows XP, or Windows Server 2003 family.
Private Declare Function DllGetVersion Lib "comctl32.dll" (ByRef version As DLLVERSIONINFO) As Integer
Function IsThisThemed() As Boolean
Dim OSInfo As OSVERSIONINFO
Dim retvalue As Integer
OSInfo.dwOSVersionInfoSize = 148
OSInfo.szCSDVersion = Space$(128)
retvalue = GetVersionExA(OSInfo)
If OSInfo.dwPlatformId = VER_PLATFORM_WIN32_NT Then
If (((OSInfo.dwMajorVersion = 5) And (OSInfo.dwMinorVersion >= 1)) Or (OSInfo.dwMajorVersion > 5)) Then
Dim version As DLLVERSIONINFO
version.cbSize = Len(version)
If DllGetVersion(version) = 0 Then
IsThisThemed = (version.dwMajorVersion > 5) And (IsThemeActive() = 1) And (IsAppThemed() = 1)
Exit Function
End If
End If
End If
IsThisThemed = False
End Function
Thursday, 12 November 2009
How to self-check for visual style in ..VB6
I've added Visual Styles (XP/Vista/W7 theme) support to a bunch of old vb6 apps. I've done this with a .manifest file and some other code, but I needed to check if visual styles are enabled. Without reading the manifest, of course. Here is the code I used to implement a IsThisTemed() function to tell if the running app has visual styles enabled. It is an adaptation of the vb.net code found here.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment