I've been writing a project in VB 6/SP 5 under Windows 2000. When I
run the app under Windows 98 or Windows 2K, everything is fine.
However, if I run it under Windows XP, some of my buttons get cut in
half at the bottom of the form. I'm sure this is because XP's
minimize/maximize/close buttons at the top of the form (the new blue
and red ones) take up more room than the ones of Win 98 and Win 2K.
If I change the Windows XP theme from the default "XP" one to "Windows
Classic," there's no problem. The form looks as good as it did under
Win 2K.
I therefore need to detect if the user is running Windows XP set to
its default theme. I've found the followintg tutorial that shows me
how to detect Windows XP:
http://vbnet.mvps.org/index.html?code/helpers/iswinversion.htm
That tut covers most of what I need to do. Now I just need to detect
if Win XP is set to the Windows Classic theme or not.
I need to:
1. Detect if the OS is Win XP.
2. If the OS is not XP, make no changes and exit the sub.
3. If the OS is Win XP, check if XP is set to the classic theme.
4. If the theme is classic, make no changes and exit the sub.
5. If the theme is not classic, adjust the form's height to a little
taller and adjust the button locations as needed to fit right.
*********************************
Just say NO to VB.NET.
Try RealBASIC.
lance - 28 Dec 2004 15:44 GMT
try working with
Private Declare Function IsThemeActive Lib "uxtheme.dll" () As Boolean
lance
> I've been writing a project in VB 6/SP 5 under Windows 2000. When I
> run the app under Windows 98 or Windows 2K, everything is fine.
[quoted text clipped - 25 lines]
> Just say NO to VB.NET.
> Try RealBASIC.
lance - 28 Dec 2004 15:55 GMT
further...
http://addressof.com/blog/archive/2004/02/15/400.aspx
lance
> try working with
>
[quoted text clipped - 31 lines]
>> Just say NO to VB.NET.
>> Try RealBASIC.
lance - 28 Dec 2004 16:00 GMT
whoops, that was the wrong link (.NYET related)
> further...
>
[quoted text clipped - 37 lines]
>>> Just say NO to VB.NET.
>>> Try RealBASIC.
lance - 28 Dec 2004 15:58 GMT
this may help.
From: "Andy DF"
Newsgroups: microsoft.public.vb.winapi
Subject: Re: How to "pick" the color of the menu bar
Ken,
1. Paste this code into a module to detect if the OS is Win XP, if XP Styles
are in use and if the application is actually using XP style:
Option Explicit
' Operating system
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type
Private Enum Enum_OperatingPlatform
Platform_Windows_32 = 0
Platform_Windows_95_98_ME = 1
Platform_Windows_NT_2K_XP = 2
End Enum
Private Enum Enum_OperatingSystem
System_Windows_32 = 0
System_Windows_95 = 1
System_Windows_98 = 2
System_Windows_ME = 3
System_Windows_NT = 4
System_Windows_2K = 5
System_Windows_XP = 6
End Enum
Private Declare Function GetVersionExA Lib "kernel32" (lpVersionInformation
As OSVERSIONINFO) As Long
' XP Theme check
Private Declare Function IsThemeActive Lib "uxtheme.dll" () As Long
Private Declare Function IsAppThemed Lib "uxtheme.dll" () As Long
' Theme check
Public Property Get isXPThemed() As Boolean
If OperatingSystem = System_Windows_XP Then isXPThemed =
CBool(IsThemeActive) And (IsAppThemed)
End Property
Private Function OperatingSystem() As Enum_OperatingSystem
Dim lpVersionInformation As OSVERSIONINFO
lpVersionInformation.dwOSVersionInfoSize = Len(lpVersionInformation)
Call GetVersionExA(lpVersionInformation)
If (lpVersionInformation.dwPlatformId = Platform_Windows_32) Then
OperatingSystem = System_Windows_32
ElseIf (lpVersionInformation.dwPlatformId = Platform_Windows_95_98_ME)
And (lpVersionInformation.dwMinorVersion = 0) Then
OperatingSystem = System_Windows_95
ElseIf (lpVersionInformation.dwPlatformId = Platform_Windows_95_98_ME)
And (lpVersionInformation.dwMinorVersion = 10) Then
OperatingSystem = System_Windows_98
ElseIf (lpVersionInformation.dwPlatformId = Platform_Windows_95_98_ME)
And (lpVersionInformation.dwMinorVersion = 90) Then
OperatingSystem = System_Windows_ME
ElseIf (lpVersionInformation.dwPlatformId = Platform_Windows_NT_2K_XP)
And (lpVersionInformation.dwMajorVersion < 5) Then
OperatingSystem = System_Windows_NT
ElseIf (lpVersionInformation.dwPlatformId = Platform_Windows_NT_2K_XP)
And (lpVersionInformation.dwMajorVersion = 5) And
(lpVersionInformation.dwMinorVersion = 0) Then
OperatingSystem = System_Windows_2K
ElseIf (lpVersionInformation.dwPlatformId = Platform_Windows_NT_2K_XP)
And (lpVersionInformation.dwMajorVersion = 5) And
(lpVersionInformation.dwMinorVersion = 1) Then
OperatingSystem = System_Windows_XP
End If
End Function
2. Win XP Menu colors:
Private Declare Function GetSysColor Lib "user32" (ByVal nIndex As Long) As
Long
Private Const COLOR_BTNFACE = 15
Private Const COLOR_MENU = 4
Private Sub MenuColors()
Dim lTopBackground As Long
Dim lMenuBackGround As Long
' Get correct MenuColors
If isXPThemed Then
' XP top menu items
lTopBackground = GetSysColor(COLOR_BTNFACE)
Else
' All other OS's top menu items
lTopBackground = GetSysColor(COLOR_MENU)
End If
' All child menu items
lMenuBackGround = GetSysColor(COLOR_MENU)
End Sub
HTH,

Signature
Andy,
pctos550@hotmail.com
Jonathan Wood - 28 Dec 2004 20:10 GMT
You can use LoadLibrary to load uxtheme.dll, which is available on XP
systems.
If it successfully loads, you can call IsAppThemed. Note that this is a bit
awkward in VB. There is a free DLL on our Web site that will allow you to do
this.
Note: IsAppThemed will return TRUE even if your application has no manifest
and, therefore, is not themed. I don't know any approach that will reliably
tell you whether or not your app has a manifest. But if your app has a
manifest, this should tell you if your app is themed or not.

Signature
Jonathan Wood
SoftCircuits
http://www.softcircuits.com
Available for consulting: http://www.softcircuits.com/jwood/resume.htm
> I've been writing a project in VB 6/SP 5 under Windows 2000. When I
> run the app under Windows 98 or Windows 2K, everything is fine.
[quoted text clipped - 25 lines]
> Just say NO to VB.NET.
> Try RealBASIC.
MikeD - 29 Dec 2004 14:17 GMT
> Note: IsAppThemed will return TRUE even if your application has no manifest
> and, therefore, is not themed. I don't know any approach that will reliably
> tell you whether or not your app has a manifest. But if your app has a
> manifest, this should tell you if your app is themed or not.
Couldn't you just check for the existance of a .manifest file in the
application folder?
Mike
alpine - 29 Dec 2004 16:21 GMT
>> Note: IsAppThemed will return TRUE even if your application has no
>manifest
[quoted text clipped - 7 lines]
>
>Mike
No, because a manifest can be compiled as a resource within the
executable.
HTH,
Bryan
____________________________________________________________
New Vision Software "When the going gets weird,"
Bryan Stafford "the weird turn pro."
alpine_don'tsendspam@mvps.org Hunter S. Thompson -
Microsoft MVP-Visual Basic Fear and Loathing in LasVegas
MikeD - 31 Dec 2004 05:28 GMT
> >> Note: IsAppThemed will return TRUE even if your application has no
> >manifest
[quoted text clipped - 10 lines]
> No, because a manifest can be compiled as a resource within the
> executable.
Ah. I didn't know that. Thanks for clearing that up. I haven't really
delved into XP themes much.
Mike
Stefan Berglund - 28 Dec 2004 23:40 GMT
in <sjr1t0phrp1ffhs8hm9sa40ho20lvps8ir@4ax.com>
>I've been writing a project in VB 6/SP 5 under Windows 2000. When I
>run the app under Windows 98 or Windows 2K, everything is fine.
[quoted text clipped - 25 lines]
>Just say NO to VB.NET.
>Try RealBASIC.
I think the real problem is that you're using Me.Height in the
resize event rather than Me.ScaleHeight as in the following
example:
If (Me.WindowState = vbMinimized) Then Exit Sub
If (Me.ScaleHeight > fraReports.Top) Then
picCommand.Top = Me.ScaleHeight - picCommand.Height
fraReports.Height = Me.ScaleHeight - picCommand.Height
List1.Height = fraReports.Height
End If
This code works regardless of the height of the XP Menu bar which
is admittedly bigger than any previous OS.
---
Stefan Berglund