//如你用的是QuickReport,那么
//用TQRExpr(比如是QRExpr2),然后在相应的OnPrint事件中写:
procedure TQR_Plan_list.QRExpr2Print(sender: TObject; var Value: String);
var
s: widestring;
s1: string;
i,j: integer;
begin
s := value; //下面判断s是否大于60个字节
if length(s)>30 then
begin
for i := 30 to 60 do
begin
s1 := copy(s,1,i); if (58-length(s1))<=0 then
begin
j := i;
break;
end;
end;
//换行
s := copy(s,1,j)+#13+Trim(copy(s,j+1,120)); value := s;
end;
end;
//注意,该处理中s最多只有两行。
//用TQRExpr(比如是QRExpr2),然后在相应的OnPrint事件中写:
procedure TQR_Plan_list.QRExpr2Print(sender: TObject; var Value: String);
var
s: widestring;
s1: string;
i,j: integer;
begin
s := value; //下面判断s是否大于60个字节
if length(s)>30 then
begin
for i := 30 to 60 do
begin
s1 := copy(s,1,i); if (58-length(s1))<=0 then
begin
j := i;
break;
end;
end;
//换行
s := copy(s,1,j)+#13+Trim(copy(s,j+1,120)); value := s;
end;
end;
//注意,该处理中s最多只有两行。
解决方案 »
- fastreport 中预览打印后,如果用命令来关闭预览窗口
- 用writeln怎么实现writeln同样的功能
- .rm文件的播放问题 大家帮忙!!
- 请问出现错误信息“undeclared indentifier:'tmp'"是什么原因阿?
- 郁闷,不爽,散分!
- 关于BLOB的读写问题!
- 请问怎么学好delphi
- 控件消息处理问题:WM_SETRECTNP?
- 使用TADOQuery.UpdateBatch时,如何对其进行错误处理?
- 非常简单的问题!!!!!!!!!!!
- delphi高手请进..........
- 各位高手:如何用delphi快速收取email-----------它的demo版程序太滥了, 收一封信需要1.5分钟
iPos :integer;
sTmp :string;
iMaxLen,iStrWidth :integer;
begin
if ((value='0') or (value='.00') or (value='.0') or (value='00')) then
begin
value:='';
exit;
end; dc := GetDC(0 ) ;
iCount := length(value);
sStrPrint := value;
iStrWidth := (Sender as TQRExpr).Width ;
sTmp := value;
try
try
ZeroMemory(@size,0);
if GetTextExtentPoint(dc,pchar(sStrPrint),icount,size) then
begin
iMaxLen := Round(( iCount * iStrWidth ) / size.cx ); //最多能显示的字符数
if icount > iMaxLen then
begin
iPos := Pos('.',value);
if iPos > 0 then //有小数点
begin
if iPos > iMaxLen+1 then //modify by czf 0725 //当整数部分字符数大于最大字符数时,整数部分也要分割
begin
value := copy(value,1,iMaxLen)+#13+copy(value,iMaxLen+1,length(value)-iMaxLen);
end
else
begin
value := copy(value,1,ipos-1)+#13+copy(value,ipos,length(value)-ipos+1);
end;
end
else //无小数点
begin
value := copy(value,1,iMaxLen)+#13+copy(value,iMaxLen+1,length(value)-iMaxLen);
end;
end;
end;
except
end;
finally
ReleaseDC(0,dc);
end;
length()得出的好象是字符数,不是字节数。可以试试这个,刚做出来的。