Try
void DrawString (CharPtr str, Short x, Short y, Short width,Boolean
rigth_justified)
{
Int strLen;
CharPtr ellipsis; //char ellipsis;
Word charsToDraw;
Short titleWidth;
CharPtr ptr;
Boolean stringFit;
RectangleType rect;
UInt pos=0;
rect.topLeft.x = x;
rect.topLeft.y = y;
rect.extent.x = width;
rect.extent.y = FntCharHeight ();
WinEraseRectangle ( &rect,0);
// Check 1: Debe existir el str
if (str == NULL || *str == '\0') return;
ptr = StrChr (str, linefeedChr);
if (ptr)
charsToDraw = (Word) (ptr - str);
else
charsToDraw = StrLen (str);
titleWidth = width;
strLen = charsToDraw;
FntCharsInWidth (str, &titleWidth, &strLen, &stringFit);
if (stringFit)
{
if (rigth_justified) WinDrawChars (str, strLen, x+width-titleWidth,
y);
else WinDrawChars (str, strLen, x, y);
}
else
{
width -= 6;
while (titleWidth > width ||
str[strLen - 1] == ' ' ||
str[strLen - 1] == tabChr)
{
titleWidth -= FntCharWidth (str[--strLen]);
}
WinDrawChars (str, strLen, x, y);
x += titleWidth;
ellipsis = "...\0";
WinDrawChars (ellipsis, 3, x, y);
}
}
Amadeu
> De: "Evgeny Rokhlin" <[EMAIL PROTECTED]>
> Responder a: "Palm Developer Forum" <[EMAIL PROTECTED]>
> Grupos: palm-dev-forum
> Fecha: Wed, 26 Apr 2000 18:53:03 +0400
> Para: "Palm Developer Forum" <[EMAIL PROTECTED]>
> Asunto: WinDrawChars problem
>
> Hi, All!
> I'm using WinDrawChars and I get strange results sometimes. The code is
> simple enough:
>
> static void List2DrawItem(UInt itemNum, RectanglePtr bounds, CharPtr
> *itemsText)
> {
> char szTranslation[MAX_WORD];
> GetTranslation(PREVIOUSWORD,itemNum,szTranslation); //szTranslation can be
> up to 60 chars
> WinDrawChars(szTranslation, StrLen(szTranslation), bounds->topLeft.x,
> bounds->topLeft.y);
> }
>
> I have a list that is 140 pixels wide. Some of the items are more wide. And
> sometimes the chars that must be outside the list are drawn! They are drawn
> out of the list and stay there forever as the area right of the list is not
> redrawn! That looks awful.
> I'm quite sure that bounds->extent.x is always equal to 138 . (less wide
> than the list).
> Does anyone have any idea what can be the reason?
> Thanx a lot.
>
>
>
>
>
> --
> For information on using the Palm Developer Forums, or to unsubscribe, please
> see http://www.palm.com/devzone/mailinglists.html
>
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palm.com/devzone/mailinglists.html