[API]
GetTextExtentExPointA
GetTextExtentExPointW

[CODE]
Public Function GetTextExtentExPoint_FitInWidth(ByVal hdc As Long, ByVal lpszStr As String, ByVal MaxWidth As Long) As Long
  Dim xLong1 As Long
  Dim xType1 As RECT
  
  xLong1 = Len(lpszStr)
  If IsUnicode Then
    xLong1 = GetTextExtentExPointW(hdc, StrPtr(lpszStr), xLong1, MaxWidth, GetTextExtentExPoint_FitInWidth, ByVal 0&, xType1)
    Else
    xLong1 = GetTextExtentExPointA(hdc, lpszStr, xLong1, MaxWidth, GetTextExtentExPoint_FitInWidth, ByVal 0&, xType1)
    End If
  If xLong1 = 0& Then
    GetTextExtentExPoint_FitInWidth = 0&
    End If
  End Function
