Advertisement
Guest User

Sub RenderTextCentered

a guest
Oct 6th, 2015
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Public Sub RenderTextCentered(ByVal lngXPos As Integer, ByVal lngYPos As Integer, ByRef strText As String, ByVal lngColor As Long, ByRef font As StdFont)
  2.     Dim hdc As Long
  3.     Dim ret As size
  4.    
  5.     If strText <> "" Then
  6.         Call BackBufferSurface.SetFont(font)
  7.        
  8.         'Get width of text once rendered
  9.        hdc = BackBufferSurface.GetDC()
  10.         Call GetTextExtentPoint32(hdc, strText, Len(strText), ret)
  11.         Call BackBufferSurface.ReleaseDC(hdc)
  12.        
  13.         lngXPos = lngXPos - ret.cx \ 2
  14.        
  15.         Call BackBufferSurface.SetForeColor(vbBlack)
  16.         Call BackBufferSurface.DrawText(lngXPos - 2, lngYPos - 1, strText, False)
  17.        
  18.         Call BackBufferSurface.SetForeColor(lngColor)
  19.         Call BackBufferSurface.DrawText(lngXPos, lngYPos, strText, False)
  20.     End If
  21. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement