On 12/30/01 5:56 PM, "Mike Benonis" <mbenonis_lists at mac dot com> wrote:
> Does anyone know of a plugin or toolbox call to truncate a string to a given
> width in pixels?
Use RB code:
Function truncString(str As String, width As Integer, theFont As String,
theSize As Integer) As String
Dim p As Picture
Dim s As String
Dim g As Graphics
p = NewPicture(1, 1, 1)
g = p.Graphics
g.TextFont = theFont
g.TextSize = theSize
s = str
While g.StringWidth(s) > width
s = Left(s, Len(s) - 1)
Wend
Return s
End Function
--
Kevin Ballard
kevin at sb dot org
http://kevin.sb.org/
|