Does anybody know an API function that returns the depth of a form's title bar. (with different display settings the depth of the title bar changes).
If not is there another way to work this out.
Any help would really be appreciated.
Printable View
Does anybody know an API function that returns the depth of a form's title bar. (with different display settings the depth of the title bar changes).
If not is there another way to work this out.
Any help would really be appreciated.
You can calculate it by useing the forms height and width and the scale height en width
The scale.... gives the size of the client area
Example:
Call it like this:Code:Private Function FormBorderWidth(ByVal frm As Form) As Long
'Form width is the complete width of the form
'Form scalewidth is the width of the client area of the form(the useable area)
'Substracting the scale witdth from the width gives the total width of the _
'non client area(borders) devide this by 2 to get the width of the individual _
'borders
FormBorderWidth = (frm.Width - frm.ScaleWidth) / 2
End Function
Private Function FormTitlebarHeight(ByVal frm As Form) As Long
'Height - scaleheight, get total non client height
'Substract 1 borderwidth (height of the bottom border)
FormTitlebarHeight = (frm.Height - frm.ScaleHeight) - FormBorderWidth(frm)
End Function
Debug.Print "Border Width: " & FormBorderWidth(Me)
Debug.Print "Titlebar Height: " & FormTitlebarHeight(Me)
Thanks Azzmodan
I will give that a go.
What about different scalemodes? And especially user, it will change from case to case. Well Azzmodan you could have this, it works for all scalemodes :)
Code:Private Function FormBorderWidth(ByVal frm As Form) As Long
'Form width is the complete width of the form
'Form scalewidth is the width of the client area of the form(the useable area)
'Substracting the scale witdth from the width gives the total width of the _
'non client area(borders) devide this by 2 to get the width of the individual _
'borders
FormBorderWidth = (frm.Width - frm.ScaleX(frm.ScaleWidth, frm.ScaleMode, vbTwips)) / 2
End Function
Private Function FormTitlebarHeight(ByVal frm As Form) As Long
'Height - scaleheight, get total non client height
'Substract 1 borderwidth (height of the bottom border)
FormTitlebarHeight = (frm.Height - ScaleY(frm.ScaleHeight, frm.ScaleMode, vbTwips)) - FormBorderWidth(frm)
End Function
Aah yes, i posted a sample from one of my old modules.
I'll pay attention to what i post next time =]