如题,其实目的就是将回车符去掉
解决方案 »
- 函数名前有下划线是什么意思?例如_WStrInsert
- Delphi中使用adoQuery+DataSource+DBChart无法生成图表的问题
- 菜鸟问题:还是关于线程。请各位高手帮帮忙。
- 还是关于word的小问题,在线等待,上一贴已结
- ********* DecisionGraph如何做饼图 ****************v
- 关闭主程序后,子程序的托盘图标还在,需鼠标移向图标才令图标消失,请教解决办法?
- C中有变量声明与定义的区别,Pascal中有吗?
- 求助:有谁能告诉我在Delphi中一个应用程序如何调用另一个应用程序
- 如何对视力中的表进行编辑?
- 糟糕的代码
- 我想在我的窗体上动态显示所查询的数据库上的记录数?怎么做?
- 关于Internet Explorer_TridentDlgFrame类,请高手来看看
i : Integer;
str : String;
begin
for i := 0 to RichEdit.lines.count -1 do
begin
str := str + RichEdit.lines.String[i];
RichEdit.lines.delete(i);
end;
richedit1.Lines.add(str);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
i : Integer;
str : String;
begin
for i := RichEdit1.lines.count -1 downto 0 do
begin
str := str + RichEdit1.lines.Strings[i];
RichEdit1.lines.delete(i);
end;
richedit1.Lines.Add(str);
end;
procedure TFormRTF.Button13Click(Sender: TObject);
var
i : Integer;
str : String;
taStyle: TTextAttributes;
begin
RichEdit1.SelectAll;
taStyle := RichEdit1.SelAttributes;
for i := RichEdit1.lines.count -1 downto 0 do
begin
str := str + RichEdit1.lines.Strings[i];
RichEdit1.lines.delete(i);
end;
richedit1.Lines.Add(str);
RichEdit1.SelectAll;
RichEdit1.SelAttributes := taStyle;
end;
如果每行的格式不同,则按下面的步骤:
(1)逐行选择,利用RichEdit的SelStart,SelLength,SelText属性;
(2)保存选择内容的TextAttributes;
(3)把选择的内容合并到相应的行;
(4)用之前保存的TextAttributes设置合并内容的TextAttributes;
RichEdit.lines.text := stringreplace(RichEdit.lines.text, #13#10, '', [rfReplaceAll]);
var
pStr: PChar;
i, j, iLen: Integer;
Str: string;
begin
for i := 0 to redt2.Lines.Count - 1 do
begin
Str := Str + redt2.Lines.Strings[i];
end;
redt2.Clear;
redt2.Lines.Add(str); pStr := @redt1.Text[1];
iLen := Length(redt1.Text);
i := 0;
j := 0;
if pStr <> nil then
begin
while i < iLen do
begin
redt1.SelStart := i;
redt1.SelLength := 1;
if (pStr[i] <> #13) and (redt1.SelText <> '')then
begin
redt2.SelStart := j;
redt2.SelLength := 1;
if redt1.SelText <> redt2.SelText then
begin
i := i - 1;
while redt1.SelText <> redt2.SelText do
begin
redt1.SelStart := i;
redt1.SelLength := 1;
if redt1.SelText = redt2.SelText then
Break;
Inc(i);
end;
end; redt2.SelStart := j;
redt2.SelLength := 1;
redt2.SelAttributes := redt1.SelAttributes; Inc(j);
end
else
begin
mmo1.Lines.Add(#10#13);
end;
Inc(i);
end;
end;
end;
SelStart,SelLength,SelAttributes
var
pStr: PChar;
i, j, iLen: Integer;
Str: string;
RichTextAttributes: array[0..1024] of TRichTextAttributes;
begin
pStr := @redt2.Text[1];
iLen := Length(redt2.Text);
for i := 0 to iLen do
begin
StrPCopy(RichTextAttributes[i].Text, pStr[i]);
redt2.SelStart := i;
redt2.SelLength := 1;
RichTextAttributes[i].taStyle := redt2.SelAttributes;
end; for i := 0 to redt2.Lines.Count - 1 do
begin
Str := Str + redt2.Lines.Strings[i];
end;
redt2.Clear;
redt2.Lines.Add(str); i := 0;
j := 0;
while i < iLen do
begin
if (RichTextAttributes[i].Text[0] <> #13) and (RichTextAttributes[i].Text <> '')then
begin
redt2.SelStart := j;
redt2.SelLength := 1;
if RichTextAttributes[i].Text <> redt2.SelText then
begin
i := i - 1;
while RichTextAttributes[i].Text <> redt2.SelText do
begin
if RichTextAttributes[i].Text = redt2.SelText then
Break;
Inc(i);
end;
end; redt2.SelStart := j;
redt2.SelLength := 1;
redt2.SelAttributes := RichTextAttributes[i].taStyle; Inc(j);
end
else
begin
mmo1.Lines.Add(#10#13);
end;
Inc(i);
end;
end;