Thanks Joe, someone else recommended this code below which works fine but I
am guessing your code is somewhat faster because you do not have the
iteration. Thanks Again,


Brian

void TrimStringToFitCell(char *string, int cell_width_pixels)
{
  if (FntCharsWidth(string, StrLen(string)) > cell_width_pixels)
  {
    cell_width_pixels -= 6;
    do
    {
      string[StrLen(string) - 1] = 0;
    } while (FntCharsWidth(string, StrLen(string)) >= cell_width_pixels);
  StrCat(string, "...");
  }
}

----- Original Message -----
From: Oguri, Joe <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Cc: 'PalmDevList' <[EMAIL PROTECTED]>; Joe Oguri
<[EMAIL PROTECTED]>
Sent: Wednesday, December 22, 1999 5:15 PM
Subject: Working Code for String Truncate: For OS 3.0


>
>    I must have 3.0 also.. there is no WinDrawTruncChars on my system. So,
> from reading the other
>   postings on how to write your own, I wrote one that works for me. This
> should save you about 45
>   seconds (120 if you have to look up the API like I did).
>
> void
> TrimString(CharPtr Str, Int Pixels)
> {
>     Int   sWid, sLen;
>     Boolean fit;
>
>     sWid = Pixels - 6;
>     sLen = StrLen(Str);
>     FntCharsInWidth(Str, &sWid, &sLen, &fit);
>     if (!fit) {
>        Str[sLen] = 0;
>        StrCat(Str, "...");
>        }
> }
>
>

Reply via email to