[API]
DrawTextW
DrawTextADirect
GrayStringW
GrayStringA

[DEFINE]
Private GrayString_DrawText_CallBack_Rect As RECT
Private GrayString_DrawText_CallBack_Mode As Long

[CODE]
Private Function GrayString_DrawText_CallBackW(ByVal hDC As Long, ByVal lpString As Long, ByVal LenText As Long) As Long
  GrayString_DrawText_CallBackW = DrawTextW(hDC, lpString, LenText, GrayString_DrawText_CallBack_Rect, GrayString_DrawText_CallBack_Mode)
  End Function

Private Function GrayString_DrawText_CallBackA(ByVal hDC As Long, ByVal lpString As Long, ByVal LenText As Long) As Long
  GrayString_DrawText_CallBackA = DrawTextADirect(hDC, lpString, LenText, GrayString_DrawText_CallBack_Rect, GrayString_DrawText_CallBack_Mode)
  End Function

Public Function GrayString_DrawText(ByVal hDC As Long, ByVal hBrush As Long, ByVal xText As String, lpRect As RECT, ByVal wFormat As Long) As Long
  Dim xLong1 As Long
  xLong1 = Len(xText)
  GrayString_DrawText_CallBack_Rect.Bottom = lpRect.Bottom - lpRect.Top
  GrayString_DrawText_CallBack_Rect.Right = lpRect.Right - lpRect.Left
  GrayString_DrawText_CallBack_Mode = wFormat
  
  If IsUnicode Then
    GrayString_DrawText = GrayStringW(hDC, hBrush, AddressOf GrayString_DrawText_CallBackW, StrPtr(xText), xLong1, lpRect.Left, lpRect.Top, GrayString_DrawText_CallBack_Rect.Right, GrayString_DrawText_CallBack_Rect.Bottom)
    Else
    GrayString_DrawText = GrayStringA(hDC, hBrush, AddressOf GrayString_DrawText_CallBackA, xText, xLong1, lpRect.Left, lpRect.Top, GrayString_DrawText_CallBack_Rect.Right, GrayString_DrawText_CallBack_Rect.Bottom)
    End If
  End Function
