I need to do a word wrapping function, but I can't use TextBox's one, because the program is DirectDraw app. The maximum length in characters is 75 for one line, and pixel size of the area we're writing to is 509*169 pixels. My sub is this (don't laugh at me!)
Code:Sub WordWrap(destRect As RECT, DDrawSurf As DirectDrawSurface7, strText As String, lngBeginX As Long, lngBeginY As Long) Dim row(1 To 10) As String Dim intBeginValue As Integer Dim xi As Integer Dim tmpval As Integer intBeginValue = 70 tmpval = Len(strText) row(1) = Left(strText, intBeginValue) row(2) = Mid(strText, intBeginValue, intBeginValue) row(3) = Mid(strText, intBeginValue * 2, intBeginValue) row(4) = Mid(strText, intBeginValue * 3, intBeginValue) row(5) = Mid(strText, intBeginValue * 4, intBeginValue) row(6) = Mid(strText, intBeginValue * 5, intBeginValue) row(7) = Mid(strText, intBeginValue * 6, intBeginValue) row(8) = Mid(strText, intBeginValue * 7, intBeginValue) row(9) = Mid(strText, intBeginValue * 8, intBeginValue) row(10) = Mid(strText, intBeginValue * 9, intBeginValue) For xi = 1 To 10 DDrawSurf.DrawText destRect.Left + lngBeginX, destRect.Top + lngBeginY + (xi * 15), row(xi), False Next End Sub




Reply With Quote