FastReport的使用,为什么在win98下汉字换行的时候出现乱码?在win2000下没事(50分)

  • 主题发起人 主题发起人 zag2000
  • 开始时间 开始时间
Z

zag2000

Unregistered / Unconfirmed
GUEST, unregistred user!
我使用的FastReport控件,2.4版本。
在使用TfrMemoView显示比较多的文本内容时,当文字超过它的宽度自动换行的时候,在
windows2000下显示很正常,但在windows98下却出现乱码,如果文字少没有换行的时候,
在98、2000下都显示正常,字体我也使用了宋体,GB2312。
不知道为什么,请教各位,急!
 
你是否修改了wrapline函数,在www.51delphi.com上有说明的
 
没有动过呀。就是下面这样的
procedure WrapLine(const s: String);
var
i, cur, beg, last, LoopPos: Integer;
WasBreak, CRLF: Boolean;
begin
CRLF := False;
LoopPos := 0;
for i := 1 to Length(s) do
if s in [#10, #13] then
begin
CRLF := True;
break;
end;
last := 1; beg := 1;
if not CRLF and ((Length(s) <= 1) or (WCanvas.TextWidth(s) <= maxwidth)) then
OutLine(s + #1)
else
begin
cur := 1;
while cur <= Length(s) do
begin
if s[cur] in [#10, #13] then
begin
OutLine(Copy(s, beg, cur - beg) + #1);
while (cur < Length(s)) and (s[cur] in [#10, #13]) do Inc(cur);
beg := cur; last := beg;
if s[cur] in [#13, #10] then
Exit else
continue;
end;
if s[cur] <> ' ' then
if WCanvas.TextWidth(Copy(s, beg, cur - beg + 1)) > maxwidth then
begin
WasBreak := False;
if (Flags and flWordBreak) <> 0 then
begin
i := cur;
while (i <= Length(s)) and not (s in spaces) do
Inc(i);
b := BreakWord(Copy(s, last + 1, i - last - 1));
if Length(b) > 0 then
begin
i := 1;
cur := last;
while (i <= Length(b)) and
(WCanvas.TextWidth(Copy(s, beg, last - beg + 1 + Ord(b)) + '-') <= maxwidth) do
begin
WasBreak := True;
cur := last + Ord(b);
Inc(i);
end;
last := cur;
end;
end
else
if last = beg then last := cur;
if WasBreak then
OutLine(Copy(s, beg, last - beg + 1) + '-')
else if s[last] = ' ' then
OutLine(Copy(s, beg, last - beg)) else
begin
OutLine(Copy(s, beg, last - beg));
Dec(last);
end;
if ((Flags and flWordBreak) <> 0) and not WasBreak and (last = cur - 1) then
if LoopPos = cur then
begin
beg := cur + 1;
cur := Length(s);
break;
end
else
LoopPos := cur;
beg := last + 1; last := beg;
end;
// if s[cur] in spaces then last := cur;
if s[cur] = ' ' then last := cur;
Inc(cur);
end;
if beg <> cur then OutLine(Copy(s, beg, cur - beg + 1) + #1);
end;
end;

 
最好处理一下你的换行函数
抄来的 我在2.47下已经通过了,解决了折行问题
来宾发言:解决fastreport 中文换行乱码(2996字节) 来宾姓名:东方蜘蛛
来宾发言:
解决中文换行乱码 ,在fr_class 查找 WrapLine 过程,替换为下面的过程,就
可以解决。
//const s:string
procedure WrapLine(const s: wideString); //解决中文换行乱码 ZWZ
var
i, cur, beg, last, LoopPos: Integer;
WasBreak, CRLF: Boolean;
begin
CRLF := False;
LoopPos := 0;
for i := 1 to Length(s) do
if (s =#10) or (s=#13) then
// if s in [#10, #13] then
begin
CRLF := True;
break;
end;
last := 1; beg := 1;
if not CRLF and ((Length(s) 〈= 1) or (WCanvas.TextWidth(s) 〈= maxwidth)) then
OutLine(s + #1)
else
begin
cur := 1;
while cur 〈= Length(s) do
begin
if (s[cur] =#10) or (s[cur]=#13) then
// if s[cur] in [#10, #13] then
begin
OutLine(Copy(s, beg, cur - beg) + #1);
while (cur 〈 Length(s)) and
((s[cur] =#10) or (s[cur]=#13))
// (s[cur] in [#10, #13])
do Inc(cur);
beg := cur; last := beg;
if (s[cur] =#10) or (s[cur]=#13) then
// if s[cur] in [#13, #10] then
Exit else
continue;
end;
if s[cur] 〈> ' ' then
if WCanvas.TextWidth(Copy(s, beg, cur - beg + 1)) > maxwidth then
begin
WasBreak := False;
if (Flags and flWordBreak) 〈> 0 then
begin
i := cur;
while (i 〈= Length(s)) and
not ((s = ' ') or (s = ' ') or (s = '.') or (s = ',') or(s = '-')) do
//not (s in spaces) do
Inc(i);
b := BreakWord(Copy(s, last + 1, i - last - 1));
if Length(b) > 0 then
begin
i := 1;
cur := last;
while (i 〈= Length(b)) and
(WCanvas.TextWidth(Copy(s, beg, last - beg + 1 + Ord(b)) + '-') 〈= maxwidth) do
begin
WasBreak := True;
cur := last + Ord(b);
Inc(i);
end;
last := cur;
end;
end
else
if last = beg then last := cur;
if WasBreak then
OutLine(Copy(s, beg, last - beg + 1) + '-')
else if s[last] = ' ' then
OutLine(Copy(s, beg, last - beg)) else
begin
OutLine(Copy(s, beg, last - beg));
Dec(last);
end;
if ((Flags and flWordBreak) 〈> 0) and not WasBreak and (last = cur - 1) then
if LoopPos = cur then
begin
beg := cur + 1;
cur := Length(s);
break;
end
else
LoopPos := cur;
beg := last + 1; last := beg;
end;
// if s[cur] in spaces then last := cur;
if s[cur] = ' ' then last := cur;
Inc(cur);
end;
if beg 〈> cur then OutLine(Copy(s, beg, cur - beg + 1) + #1);
end;
end;
 
查看评论,和修改方法
http://www.51delphi.com/delphi/showsoftpl?id=14
 
多人接受答案了。
 
后退
顶部