|
-
Feb 25th, 2004, 11:01 PM
#1
getting the titleBar height
can someone just double-check my code? cuz it seems to be working almost fine except its one pixel off for some reason
VB Code:
Public ReadOnly Property TitleBarHeight(ByVal bStyle As FormBorderStyle) As Integer
Get
Select Case bStyle
Case FormBorderStyle.Fixed3D
Return SystemInformation.CaptionHeight + _
2 * SystemInformation.Border3DSize.Height
Case FormBorderStyle.Sizable, FormBorderStyle.FixedSingle, FormBorderStyle.FixedDialog
Return SystemInformation.CaptionHeight + _
2 * SystemInformation.Border3DSize.Height
Case FormBorderStyle.FixedToolWindow, FormBorderStyle.SizableToolWindow
Return SystemInformation.ToolWindowCaptionHeight + _
2 * SystemInformation.Border3DSize.Height
Case FormBorderStyle.None
Return 0
End Select
End Get
End Property
The first case switch returns a value 1 pixel less than the actual value, and the second case statement returns 1 pixel more than the actual value. I think I'm using the right stuff, why isn't it working correctly?
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Feb 25th, 2004, 11:18 PM
#2
hmm this seems to be working fine, except I dont know where the +1 at end comes from
I noticed that sizable forms are 1 pixel bigger
VB Code:
Public ReadOnly Property TitleBarHeight(ByVal bStyle As FormBorderStyle) As Integer
Get
Dim border, height As Integer
If bStyle = FormBorderStyle.SizableToolWindow OrElse _
bStyle = FormBorderStyle.Sizable Then
border = 1
End If
Select Case bStyle
Case FormBorderStyle.Fixed3D
height = SystemInformation.CaptionHeight
border += 2 * SystemInformation.Border3DSize.Height
Case FormBorderStyle.Sizable, _
FormBorderStyle.FixedSingle, _
FormBorderStyle.FixedDialog
height = SystemInformation.CaptionHeight
border += 2 * SystemInformation.BorderSize.Height
Case FormBorderStyle.FixedToolWindow, _
FormBorderStyle.SizableToolWindow
height = SystemInformation.ToolWindowCaptionHeight
border += 2 * SystemInformation.BorderSize.Height
Case FormBorderStyle.None
Return 0
End Select
Return height + border + 1
End Get
End Property
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Feb 26th, 2004, 04:19 AM
#3
Hi.
I haven't tried this. I just thought this might do the trick, regardsless of FormBorderStyle.
VB Code:
TitleHeight = Me.Height - Me.ClientSize-Height
As far as I know, the Height is the actual height of the entire form/control, where ClientSize.Height is the height available to the user. Hence I think that the difference between the two must be the titlebar height. If the form has no border the height would return 0.
I hope this is of any help...
I wish I could think of something witty to put in my sig...
...Currently using VS2013...
-
Feb 26th, 2004, 05:40 PM
#4
Originally posted by pax
Hi.
I haven't tried this. I just thought this might do the trick, regardsless of FormBorderStyle.
VB Code:
TitleHeight = Me.Height - Me.ClientSize-Height
As far as I know, the Height is the actual height of the entire form/control, where ClientSize.Height is the height available to the user. Hence I think that the difference between the two must be the titlebar height. If the form has no border the height would return 0.
I hope this is of any help...
that's what I've always been using, but apprently it doesnt give you the correct height (I get a screenshot of the form and measure the titlebar in pixels using msPaint and it appears to be a different value when I use that code. But so far my code is working correctly )
edit: plus I think there was another problem with that. I think when I had a main menu then clientSize would become smaller and therefore I would get a value that was way off for the titlebar
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
-
Feb 27th, 2004, 05:59 AM
#5
Originally posted by MrPolite
that's what I've always been using, but apprently it doesnt give you the correct height (I get a screenshot of the form and measure the titlebar in pixels using msPaint and it appears to be a different value when I use that code. But so far my code is working correctly )
Strange...perhaps it has something to do with visual styles...
edit: plus I think there was another problem with that. I think when I had a main menu then clientSize would become smaller and therefore I would get a value that was way off for the titlebar
Right, didn't think of that...
hmm, perhaps the GetTitleBarInfo API could do the trick.
I wish I could think of something witty to put in my sig...
...Currently using VS2013...
-
Feb 27th, 2004, 06:20 AM
#6
Forget this post...things went wrong...
Last edited by pax; Feb 27th, 2004 at 06:31 AM.
I wish I could think of something witty to put in my sig...
...Currently using VS2013...
-
Feb 27th, 2004, 12:39 PM
#7
rate my posts if they help ya!
Extract thumbnail without reading the whole image file: (C# - VB)
Apply texture to bitmaps: (C# - VB)
Extended console library: (VB)
Save JPEG with a certain quality (image compression): (C# - VB )
VB.NET to C# conversion tips!!
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
|