function GetWordWrap(var pSrc: PChar; pDst: PChar; iMax: Integer): Integer;
var
i: Integer;
begin
Result := 0;
for i := 1 to iMax do //这里出现问题,当我一跟踪的话,i 一直是 34 ,不知道为什么?
begin
pDst^ := pSrc^;
if (pSrc^ = #0) then Break;
if (pSrc^ = #10) then
begin
inc(pSrc, 2);
pDst^ := #0;
Break;
end;
inc(pDst);
inc(pSrc);
inc(Result);
end;
if (Ord(pDst^) > 128) then
begin
pDst^ := pSrc^;
inc(pSrc);
inc(pDst);
end;
pDst := #0;
end;
调用:
while (GetWordWrap(pStr, @tpStr[0], 6) > 0) do
begin
yy := yy + 3 + Abs(Canvas.Font.Height);//输出位置向下
Canvas.TextOut(xx, yy, tpStr);
end;