全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1188
推到 Plurk!
推到 Facebook!

delphi7所附Rave5之dbMemo控件断行问题

尚未結案
yeliang
一般會員


發表:1
回覆:6
積分:1
註冊:2003-05-12

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-05-13 12:49:33 IP:61.154.xxx.xxx 未訂閱
delphi7所附Rave5之dbMemo控件,在中文一行不能打印完时能够自动断行,但不能按整字来断行,有时一个中文字会被截断,造成下行的混乱. 若人工或程序加空格应该可以解决,但都不够好,有根本解决办法吗? 發表人 - yeliang 於 2003/05/13 12:52:27 發表人 - yeliang 於 2003/05/13 12:54:53 發表人 - yeliang 於 2003/05/13 12:57:17
hlf1kimo
一般會員


發表:5
回覆:3
積分:1
註冊:2003-06-13

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-06-16 14:09:39 IP:211.21.xxx.xxx 未訂閱
我試了一下, RAVE5 的 dbMeno元件在設計階段的預覽時會出現斷行現象, 但在程式執行時的就不會斷行了, 試試看
yeliang
一般會員


發表:1
回覆:6
積分:1
註冊:2003-05-12

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-06-17 08:03:37 IP:61.154.xxx.xxx 未訂閱
谢谢楼上,但我试过了还不行,包括印到纸上都不行. 预览与实际运行似乎有些差别,只在于断字的位置不同.但都会把中文字从中间断掉.特别是某字段值是中英文混合的更容易出问题.
SCYANGYU1427
一般會員


發表:1
回覆:14
積分:3
註冊:2002-09-09

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-03-13 11:38:04 IP:61.170.xxx.xxx 未訂閱
我髮現是下麵兩個函數的問題! 哪位大俠能否解決? 第一個函數是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

發送簡訊給我
#5 引用回覆 回覆 發表時間:2004-03-13 11:38:24 IP:61.170.xxx.xxx 未訂閱
我髮現是下麵兩個函數的問題! 哪位大俠能否解決? 第一个函数是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

發送簡訊給我
#6 引用回覆 回覆 發表時間:2005-01-20 17:35:38 IP:61.51.xxx.xxx 未訂閱
//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

發送簡訊給我
#7 引用回覆 回覆 發表時間:2005-01-20 17:41:41 IP:61.51.xxx.xxx 未訂閱
//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

發送簡訊給我
#8 引用回覆 回覆 發表時間:2005-01-20 17:42:00 IP:61.51.xxx.xxx 未訂閱
//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
系統時間:2024-05-17 14:47:32
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!