Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you calculate the height of the title bar in VB6?

Tags:

vb6

I'm trying to display one form relative to a Button on a control below it.

But Button.top is relative to the titlebar of the bottom form, and the top form will be relative to the screen.

So, to compensate for that I need to now how tall the titlebar is.

I've used Form.height-Form.ScalehHeight but ScaleHeight doesn't include the title bar or the border so Scaleheight is inflated slightly.

Anyone know how to calculate the height of just the title bar?

like image 435
Clay Nichols Avatar asked Jan 30 '09 22:01

Clay Nichols


2 Answers

You need to use the GetSystemMetrics API call to get the height of the titlebar.

Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Private Const SM_CYCAPTION = 4

Property Get TitleBarHeight() as Long
    TitleBarHeight = GetSystemMetrics(SM_CYCAPTION)
End Property

Note: This will return the height in pixels. If you need twips you will have to convert using a form's ScaleY method like so: Me.ScaleY(TitleBarHeight(), vbPixels, vbTwips)

like image 74
rpetrich Avatar answered Sep 30 '22 20:09

rpetrich


Subtract it back out:

(Form.height-Form.ScaleHeight) - (Form.Width-Form.ScaleWidth) / 2
like image 31
recursive Avatar answered Sep 30 '22 20:09

recursive