|
-
Oct 20th, 2005, 03:12 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] XP Theme / Win Classic Form Height
What does everyone think about this?
The application I'm working on is run on a variety of different PCs, some XP, others not.
On PCs set up with XP Theme display the forms' caption bars are thicker, making the available space on the form smaller. Most of our forms were designed before XP so many of them end up with some of the controls almost falling off the bottom.
The following code appears to solve the problem, sizing the form appropriately for both XP and non-XP.
Can anyone think of any problems with this? Are there other display modes I haven't thought about?
The 405 value is the height of the title bar in Windows Classic. The height of the title bar in XP Themes is 510.
VB Code:
Private Sub Form_Load()
Dim vDesiredHeight As Single
vDesiredHeight = 5000
Height = vDesiredHeight
Height = Height - 405 + (Height - ScaleHeight)
End Sub
This world is not my home. I'm just passing through.
-
Oct 20th, 2005, 12:10 PM
#2
Re: XP Theme / Win Classic Form Height
The only problem will be if the user is using a custom theme which has a different titlebar height then the two. There is an API that can get the info.
VB Code:
Option Explicit
Private Const CCHILDREN_TITLEBAR = 5
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type TITLEBARINFO
cbSize As Long
rcTitleBar As RECT
rgstate(CCHILDREN_TITLEBAR) As Long
End Type
Private Declare Function GetTitleBarInfo Lib "user32.dll" (ByVal hwnd As Long, ByRef pti As TITLEBARINFO) As Long
Private Sub Command1_Click()
Dim nfoTitle As TITLEBARINFO
nfoTitle.cbSize = Len(nfoTitle)
GetTitleBarInfo Me.hwnd, nfoTitle
MsgBox (nfoTitle.rcTitleBar.Bottom - nfoTitle.rcTitleBar.Top) * Screen.TwipsPerPixelY
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Oct 20th, 2005, 12:31 PM
#3
Re: XP Theme / Win Classic Form Height
Another problem is that is the Scalemode of the form is not Twips then it won't work out. To fix this problem do this
VB Code:
Height = Height - 405 + (Height - ScaleY(ScaleHeight, ScaleMode, vbTwips))
And of course implement the Dog's suggestion.
-
Oct 21st, 2005, 04:46 AM
#4
Thread Starter
Frenzied Member
Re: XP Theme / Win Classic Form Height
Thanks to both of you.
I think I can avoid using GetTitleBarInfo because I can garauntee that the forms will be designed under XP Themes (I will be using a titlebar height of 510 rather than 405).
The resizing is only required if the user is running a different display mode/theme to the designer. Height-ScaleHeight returns the height of the titlebar so I'm going with moeur's suggestion (and changing the 405 to 510 as mentioned before).
Reputation added to you both though.
This world is not my home. I'm just passing through.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|