K
Kay L.
Hi, when I draw a long text inside a rect, it will go outside, I want to
know which charactor is the last one which is inside the rect. I know I can
do like below, but it's not efficient, is there any better way to do this,
thanks.
CString str = "a long text"; // if it's too long, I want to draw "a long
t...";
CRect rc(0,0,100,100);
char c;
for(int i=0; i<str.GetLength(); i++)
{
CSize sz = pDC->GetTextExtent(0,0,str);
if(sz.cy > rc.Width())
{
c = str.GetAt(i);
break;
}
}
know which charactor is the last one which is inside the rect. I know I can
do like below, but it's not efficient, is there any better way to do this,
thanks.
CString str = "a long text"; // if it's too long, I want to draw "a long
t...";
CRect rc(0,0,100,100);
char c;
for(int i=0; i<str.GetLength(); i++)
{
CSize sz = pDC->GetTextExtent(0,0,str);
if(sz.cy > rc.Width())
{
c = str.GetAt(i);
break;
}
}