Can some please explain what I'm doing wrong.
I set the textbox font to "Tahoma", Fontsize = 9
and IMHO TEXTMETRICS should return that same value BUT does NOT??
Code:Private Sub GetFontHeight() Dim hDC As Long Dim hWnd As Long 'Individual Font Variables Dim mymetrics As TEXTMETRIC Dim savey As Single Dim InternalLeading As Single Dim Ascent As Single Dim Descent As Single Dim ExternalLeading As Single Dim txtHeight As Integer Dim txtHeight1 As Integer Dim convert As Long Dim convert1 As Long '-------------------------------- Me.ScaleMode = vbPixels 'Form in Pixels With Me.Text1 .FontName = "Tahoma" .FontSize = 9 hWnd = .hWnd End With hDC = GetDC(hWnd) '----------------------- 'Get Font Part Details Using API '------------------------ GetTextMetrics hDC, mymetrics InternalLeading = mymetrics.tmInternalLeading Ascent = mymetrics.tmAscent Descent = mymetrics.tmDescent ExternalLeading = mymetrics.tmExternalLeading txtHeight = Ascent + Descent txtHeight1 = Ascent + Descent - InternalLeading End Sub




Reply With Quote