>Does anyone have an equivalent
>function that I can use that is not so big?

Caveat Emptor. I'm sure there are cases where this won't work. 
(ellipsis may be different on different OS versions, totally wrong 
for multi-byte strings, etc.).

Regards,
Steve Mann

/***********************************************************************
  * FUNCTION:           UTTruncateString
  *
  * DESCRIPTION:        Truncate a string to a maximum # of pixels.
  *
  * RETURNED:           Nothing
***********************************************************************/
void    UTTruncateString
(
        Char *          strP,   // ( in/out ) the string to truncate
        Int16           width,  // ( in ) the max # of pixels to allow
        FontID          font    // ( in ) the font to calculate the width in
)
{
        Int16           strLength       = StrLen ( strP );
        Int16           strWidth                = width;
        FontID          oldFont                 = FntSetFont ( font );
        Boolean                 truncated;

// Get the max # chars that can be displayed

        FntCharsInWidth ( strP, &strWidth, &strLength, &truncated );
        FntSetFont ( oldFont );

// Truncate the title and add trailing ellipsis.

        if ( strLength < StrLen ( strP ))
        {
                strP [ strLength - 1 ] = 24;    // ellipsis
                strP [ strLength ] = '\0';      // truncate
        }
}
-- 
-------------------------------------------
Creative Digital Publishing Inc.
1315 Palm Street, San Luis Obispo, CA 93401-3117
-------------------------------------------
805.784.9461              805.784.9462 (fax)
[EMAIL PROTECTED]       http://www.cdpubs.com

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to