MENUS
Set up popup menus with a fixed size
There is actually a Toolbox function that does exactly this. It's called TruncText, and it will truncate long strings to whatever pixel width you specify, and will insert an elipsis (...) on the right or in the middle of the returned string. See Inside Mac for details:
http://dev.info.apple.com/techpubs/mac/Text/Text-326.html
Here is a FutureBasic implementation:
'------LOCAL FN TruncText(pixWidth, textPtr&, lengthAddr&, truncWhere)
'Call as follows:
' result = FN TruncText(pixWidth, textPtr&, @length, truncWhere)
DIM result
` clr.w -(sp)
` move.w ^pixWidth,-(sp)
` move.l ^textPtr&,-(sp)
` move.l ^lengthAddr&,-(sp)
` move.w ^truncWhere,-(sp)
` move.l #$820CFFDE,-(sp)
` dc.w $A8B5
` move.w (sp)+,^result
END FN = result
'------
Rick forgot to post the constants required.
They are:
REM Constants for truncWhere argument in TruncString and TruncText
_truncEnd = 0 'truncate at end
_truncMiddle = &4000 '(Decimal 16,384?) truncate in middle
REM Constants for TruncString and TruncText results
_NotTruncated = 0 'no truncation was necessary
_Truncated = 1 'truncation performed
_TruncErr = -1 'general error
|