delphi7所附Rave5之dbMemo控件断行问题 |
尚未結案
|
yeliang
一般會員 發表:1 回覆:6 積分:1 註冊:2003-05-12 發送簡訊給我 |
|
hlf1kimo
一般會員 發表:5 回覆:3 積分:1 註冊:2003-06-13 發送簡訊給我 |
|
yeliang
一般會員 發表:1 回覆:6 積分:1 註冊:2003-05-12 發送簡訊給我 |
|
SCYANGYU1427
一般會員 發表:1 回覆:14 積分:3 註冊:2002-09-09 發送簡訊給我 |
我髮現是下麵兩個函數的問題! 哪位大俠能否解決? 第一個函數是RpMemo單元中的TMemoBuf.GetLine。 function TMemoBuf.GetLine( Width: longint;
var Eol: boolean): string;
var
TestWidth: longint;
SavePos: longint;
NewWord: string;
S1: string;
S2: string;
StartPos: longint;
FormatState: TFormatState;
StartState: string;
AdjWidth: longint;
FirstLine: boolean;
begin { GetLine }
{ Get a line of text that will fit within PrintStart to PrintEnd }
EOL := false;
NewLine := true;
StartPos := -1;
S1 := '';
S2 := '';
StartState := '';
Result := '';
FirstLine := NewParagraph;
AdjWidth := Width; repeat
SavePos := FPos; { Save off current position }
NewWord := GetWord; { Get next word } if StartPos < 0 then
begin { Initial run through }
StartPos := NonSpacePos;
if HasRPTF then
begin { Get state of line start }
FormatState := GetStateAtPos(SavePos);
StartState := StateToRPTF(FormatState);
if FirstLine then
begin
LeftIndent := FormatState.Para.FirstIndent FormatState.Para.LeftIndent;
end else begin
LeftIndent := FormatState.Para.LeftIndent;
end; { else }
RightIndent := FormatState.Para.RightIndent;
AdjWidth := Width - Round((LeftIndent RightIndent) * BaseReport.XDPI);
if AdjWidth < BaseReport.XDPI then begin { Don't allow width less than 1" }
AdjWidth := BaseReport.XDPI;
end; { if }
end; { if }
end; { if } if (NewWord = #13) or (NewWord = '') then
begin { Finish off line }
EOL := true;
if Result = '' then
begin
Result := StartState;
end; { if }
Break;
end
else
begin { Test width with new word }
S2 := S2 NewWord;
S1 := StartState FillRPTF(S2,StartPos); if System.Pos(RPTFPrefix,S1) = 0 then
begin
TestWidth := SimpleTextWidth(BaseReport,S1,0);
end else begin
TestWidth := RPTFTextWidth(BaseReport,S1);
end; { else } if TestWidth <= AdjWidth then begin { Add new word }
Result := S1;
end else begin { Reset position to before this word }
FPos := SavePos;
end; { else } if TestWidth >= AdjWidth then
begin
if UnformatLen(Result) = 0 then
begin { First word was too long, cut it down }
repeat { Add on characters until enough width }
S1 := Result;
while FBuffer^[FPos] = RPTFPrefix do
begin { Add on RPTF stuff }
repeat
S1 := S1 FBuffer^[FPos];
Inc(FPos);
until FBuffer^[FPos] = RPTFSuffix;
S1 := S1 FBuffer^[FPos];
Inc(FPos);
end; { while }
S1 := S1 FBuffer^[FPos];
if System.Pos(RPTFPrefix,S1) = 0 then
begin
TestWidth := SimpleTextWidth(BaseReport,S1,0);
end else begin
TestWidth := RPTFTextWidth(BaseReport,S1);
end; { else }
if TestWidth <= AdjWidth then
begin
if S1 = ' ' then
begin
Result := '';
end
else
begin
Result := S1;
end; { else }
Inc(FPos);
end; { if }
until (TestWidth >= AdjWidth) or (FPos >= FSize);
end; { if }
Break;
end; { if }
end; { else }
until false;
end; { GetLine } 另外一個函數是QRpMemo單元中的TMemoBuf.GetLine。 function TMemoBuf.GetLine( Width: longint;
var Eol: boolean): string;
var
TestWidth: longint;
SavePos: longint;
NewWord: string;
S1: string;
S2: string;
StartPos: longint;
FormatState: TFormatState;
StartState: string;
AdjWidth: longint;
FirstLine: boolean;
begin { GetLine }
{ Get a line of text that will fit within PrintStart to PrintEnd }
EOL := false;
NewLine := true;
StartPos := -1;
S1 := '';
S2 := '';
StartState := '';
Result := '';
FirstLine := NewParagraph;
AdjWidth := Width; repeat
SavePos := FPos; { Save off current position }
NewWord := GetWord; { Get next word } if StartPos < 0 then
begin { Initial run through }
StartPos := NonSpacePos;
if HasRPTF then
begin { Get state of line start }
FormatState := GetStateAtPos(SavePos);
StartState := StateToRPTF(FormatState);
if FirstLine then
begin
LeftIndent := FormatState.Para.FirstIndent FormatState.Para.LeftIndent;
end else begin
LeftIndent := FormatState.Para.LeftIndent;
end; { else }
RightIndent := FormatState.Para.RightIndent;
AdjWidth := Width - Round((LeftIndent RightIndent) * BaseReport.XDPI);
if AdjWidth < BaseReport.XDPI then begin { Don't allow width less than 1" }
AdjWidth := BaseReport.XDPI;
end; { if }
end; { if }
end; { if } if (NewWord = #13) or (NewWord = '') then
begin { Finish off line }
EOL := true;
if Result = '' then begin
Result := StartState;
end; { if }
Break;
end else
begin { Test width with new word }
S2 := S2 NewWord;
S1 := StartState FillRPTF(S2,StartPos); if System.Pos(RPTFPrefix,S1) = 0 then
begin
TestWidth := SimpleTextWidth(BaseReport,S1,0);
end else begin
TestWidth := RPTFTextWidth(BaseReport,S1);
end; { else } if TestWidth <= AdjWidth then
begin { Add new word }
Result := S1;
end else begin { Reset position to before this word }
FPos := SavePos;
end; { else } if TestWidth >= AdjWidth then
begin
if UnformatLen(Result) = 0 then
begin { First word was too long, cut it down }
repeat { Add on characters until enough width }
S1 := Result;
while FBuffer^[FPos] = RPTFPrefix do
begin { Add on RPTF stuff }
repeat
S1 := S1 FBuffer^[FPos];
Inc(FPos);
until FBuffer^[FPos] = RPTFSuffix;
S1 := S1 FBuffer^[FPos];
Inc(FPos);
end; { while }
S1 := S1 FBuffer^[FPos];
if System.Pos(RPTFPrefix,S1) = 0 then
begin
TestWidth := SimpleTextWidth(BaseReport,S1,0);
end else
begin
TestWidth := RPTFTextWidth(BaseReport,S1);
end; { else }
if TestWidth <= AdjWidth then
begin
if S1 = ' ' then
begin
Result := '';
end
else
begin
Result := S1;
end; { else }
Inc(FPos);
end; { if }
until (TestWidth >= AdjWidth) or (FPos >= FSize);
end; { if }
Break;
end; { if }
end; { else }
until false;
end; { GetLine } 發表人 - SCYANGYU1427 於 2004/03/13 11:40:50
|
SCYANGYU1427
一般會員 發表:1 回覆:14 積分:3 註冊:2002-09-09 發送簡訊給我 |
我髮現是下麵兩個函數的問題! 哪位大俠能否解決? 第一个函数是RpMemo单元中的TMemoBuf.GetLine。 function TMemoBuf.GetLine( Width: longint;
var Eol: boolean): string;
var
TestWidth: longint;
SavePos: longint;
NewWord: string;
S1: string;
S2: string;
StartPos: longint;
FormatState: TFormatState;
StartState: string;
AdjWidth: longint;
FirstLine: boolean;
begin { GetLine }
{ Get a line of text that will fit within PrintStart to PrintEnd }
EOL := false;
NewLine := true;
StartPos := -1;
S1 := '';
S2 := '';
StartState := '';
Result := '';
FirstLine := NewParagraph;
AdjWidth := Width; repeat
SavePos := FPos; { Save off current position }
NewWord := GetWord; { Get next word } if StartPos < 0 then
begin { Initial run through }
StartPos := NonSpacePos;
if HasRPTF then
begin { Get state of line start }
FormatState := GetStateAtPos(SavePos);
StartState := StateToRPTF(FormatState);
if FirstLine then
begin
LeftIndent := FormatState.Para.FirstIndent FormatState.Para.LeftIndent;
end else begin
LeftIndent := FormatState.Para.LeftIndent;
end; { else }
RightIndent := FormatState.Para.RightIndent;
AdjWidth := Width - Round((LeftIndent RightIndent) * BaseReport.XDPI);
if AdjWidth < BaseReport.XDPI then begin { Don't allow width less than 1" }
AdjWidth := BaseReport.XDPI;
end; { if }
end; { if }
end; { if } if (NewWord = #13) or (NewWord = '') then
begin { Finish off line }
EOL := true;
if Result = '' then
begin
Result := StartState;
end; { if }
Break;
end
else
begin { Test width with new word }
S2 := S2 NewWord;
S1 := StartState FillRPTF(S2,StartPos); if System.Pos(RPTFPrefix,S1) = 0 then
begin
TestWidth := SimpleTextWidth(BaseReport,S1,0);
end else begin
TestWidth := RPTFTextWidth(BaseReport,S1);
end; { else } if TestWidth <= AdjWidth then begin { Add new word }
Result := S1;
end else begin { Reset position to before this word }
FPos := SavePos;
end; { else } if TestWidth >= AdjWidth then
begin
if UnformatLen(Result) = 0 then
begin { First word was too long, cut it down }
repeat { Add on characters until enough width }
S1 := Result;
while FBuffer^[FPos] = RPTFPrefix do
begin { Add on RPTF stuff }
repeat
S1 := S1 FBuffer^[FPos];
Inc(FPos);
until FBuffer^[FPos] = RPTFSuffix;
S1 := S1 FBuffer^[FPos];
Inc(FPos);
end; { while }
S1 := S1 FBuffer^[FPos];
if System.Pos(RPTFPrefix,S1) = 0 then
begin
TestWidth := SimpleTextWidth(BaseReport,S1,0);
end else begin
TestWidth := RPTFTextWidth(BaseReport,S1);
end; { else }
if TestWidth <= AdjWidth then
begin
if S1 = ' ' then
begin
Result := '';
end
else
begin
Result := S1;
end; { else }
Inc(FPos);
end; { if }
until (TestWidth >= AdjWidth) or (FPos >= FSize);
end; { if }
Break;
end; { if }
end; { else }
until false;
end; { GetLine } 另外一个函数是QRpMemo单元中的TMemoBuf.GetLine。 function TMemoBuf.GetLine( Width: longint;
var Eol: boolean): string;
var
TestWidth: longint;
SavePos: longint;
NewWord: string;
S1: string;
S2: string;
StartPos: longint;
FormatState: TFormatState;
StartState: string;
AdjWidth: longint;
FirstLine: boolean;
begin { GetLine }
{ Get a line of text that will fit within PrintStart to PrintEnd }
EOL := false;
NewLine := true;
StartPos := -1;
S1 := '';
S2 := '';
StartState := '';
Result := '';
FirstLine := NewParagraph;
AdjWidth := Width; repeat
SavePos := FPos; { Save off current position }
NewWord := GetWord; { Get next word } if StartPos < 0 then
begin { Initial run through }
StartPos := NonSpacePos;
if HasRPTF then
begin { Get state of line start }
FormatState := GetStateAtPos(SavePos);
StartState := StateToRPTF(FormatState);
if FirstLine then
begin
LeftIndent := FormatState.Para.FirstIndent FormatState.Para.LeftIndent;
end else begin
LeftIndent := FormatState.Para.LeftIndent;
end; { else }
RightIndent := FormatState.Para.RightIndent;
AdjWidth := Width - Round((LeftIndent RightIndent) * BaseReport.XDPI);
if AdjWidth < BaseReport.XDPI then begin { Don't allow width less than 1" }
AdjWidth := BaseReport.XDPI;
end; { if }
end; { if }
end; { if } if (NewWord = #13) or (NewWord = '') then
begin { Finish off line }
EOL := true;
if Result = '' then begin
Result := StartState;
end; { if }
Break;
end else
begin { Test width with new word }
S2 := S2 NewWord;
S1 := StartState FillRPTF(S2,StartPos); if System.Pos(RPTFPrefix,S1) = 0 then
begin
TestWidth := SimpleTextWidth(BaseReport,S1,0);
end else begin
TestWidth := RPTFTextWidth(BaseReport,S1);
end; { else } if TestWidth <= AdjWidth then
begin { Add new word }
Result := S1;
end else begin { Reset position to before this word }
FPos := SavePos;
end; { else } if TestWidth >= AdjWidth then
begin
if UnformatLen(Result) = 0 then
begin { First word was too long, cut it down }
repeat { Add on characters until enough width }
S1 := Result;
while FBuffer^[FPos] = RPTFPrefix do
begin { Add on RPTF stuff }
repeat
S1 := S1 FBuffer^[FPos];
Inc(FPos);
until FBuffer^[FPos] = RPTFSuffix;
S1 := S1 FBuffer^[FPos];
Inc(FPos);
end; { while }
S1 := S1 FBuffer^[FPos];
if System.Pos(RPTFPrefix,S1) = 0 then
begin
TestWidth := SimpleTextWidth(BaseReport,S1,0);
end else
begin
TestWidth := RPTFTextWidth(BaseReport,S1);
end; { else }
if TestWidth <= AdjWidth then
begin
if S1 = ' ' then
begin
Result := '';
end
else
begin
Result := S1;
end; { else }
Inc(FPos);
end; { if }
until (TestWidth >= AdjWidth) or (FPos >= FSize);
end; { if }
Break;
end; { if }
end; { else }
until false;
end; { GetLine }
|
daniel_willian
一般會員 發表:0 回覆:4 積分:0 註冊:2005-01-14 發送簡訊給我 |
//SCYANGYU ************** Start **************
Function CurLineEndHalfCHS(Const CurLineStr:String):Boolean;
Var
bIsDBCS:Boolean;
jLength,jFor:Integer;
Begin
bIsDBCS := False;
jLength:=Length(CurLineStr);
for jFor := 1 to jLength do
begin
if bIsDBCS then
bIsDBCS := False
else
Begin
if Windows.IsDBCSLeadByte(byte(CurLineStr[jFor])) then
bIsDBCS := True;
End;
end; //end of for
Result:=bIsDBCS;
End;
//SCYANGYU ************** End **************
这位先生,其中的“Windows”在什么地方定义的,我编译的时候通不过呀!
------
how are you |
daniel_willian
一般會員 發表:0 回覆:4 積分:0 註冊:2005-01-14 發送簡訊給我 |
//SCYANGYU ************** Start **************
Function CurLineEndHalfCHS(Const CurLineStr:String):Boolean;
Var
bIsDBCS:Boolean;
jLength,jFor:Integer;
Begin
bIsDBCS := False;
jLength:=Length(CurLineStr);
for jFor := 1 to jLength do
begin
if bIsDBCS then
bIsDBCS := False
else
Begin
if Windows.IsDBCSLeadByte(byte(CurLineStr[jFor])) then
bIsDBCS := True;
End;
end; //end of for
Result:=bIsDBCS;
End;
//SCYANGYU ************** End **************
刚才上传有一点问题,重新上传;
SCYANGYU1427先生:Windows在什么地方定义的,编译的时候通不过呀! how are you
------
how are you |
daniel_willian
一般會員 發表:0 回覆:4 積分:0 註冊:2005-01-14 發送簡訊給我 |
//SCYANGYU ************** Start **************
Function CurLineEndHalfCHS(Const CurLineStr:String):Boolean;
Var
bIsDBCS:Boolean;
jLength,jFor:Integer;
Begin
bIsDBCS := False;
jLength:=Length(CurLineStr);
for jFor := 1 to jLength do
begin
if bIsDBCS then
bIsDBCS := False
else
Begin
if Windows.IsDBCSLeadByte(byte(CurLineStr[jFor])) then
bIsDBCS := True;
End;
end; //end of for
Result:=bIsDBCS;
End;
//SCYANGYU ************** End **************
刚才上传有一点问题,重新上传;
SCYANGYU1427先生:Windows在什么地方定义的,编译的时候通不过呀! how are you
------
how are you |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |