參考網址:http://delphi.ktop.com.tw/board.php?cid=30&fid=100&tid=44298
屬性需設定
AutoSize = false
AutoStretch = true
WordWrap = true
function ApartString(InStr : String ;MaxLen : Integer) : String;
var
P: Integer;
S,L : String;
OriStr : Array[0..1000] OF Char;
OutStr : String;
begin
P := 0;
L := '';
OutStr := '';
StrPCopy(OriStr,InStr);
WHILE P <= Length(InStr) - 1 DO
BEGIN
IF ORD(OriStr[P]) > 127 THEN
BEGIN
S := Copy(OriStr,P + 1,2);
Inc(p)
END
ELSE
BEGIN
S := Copy(OriStr,P + 1,1);
END;
Inc(p);
IF Length(L + S) > MaxLen Then
BEGIN
OutStr := OutStr + L + #13;
L := S;
END
ELSE
BEGIN
L := L + S;
END;
END;
OutStr := OutStr + L;
ApartString := OutStr;
end;
在OnPrint的地方
procedure TPNameCard.QRDBText4Print(sender: TObject; var Value: string);
var
I : Integer;
OriStr : Array[0..1000] OF Char;
V_Chinese : Boolean;
begin
IF Not (Sender AS TQRDBText).AutoSize THEN
BEGIN
StrPCopy(OriStr,Value);
V_Chinese := False;
FOR I := 0 TO Length(Value) - 1 DO
BEGIN
IF ORD(OriStr[I]) > 127 THEN
BEGIN
V_Chinese := True;
Break;
END;
END;
IF V_Chinese THEN
Value := ApartString(Value,20)
ELSE
Value := Value;
END;
end;
沒有留言:
張貼留言