var
Form1: TForm1;
const
defaultfilename='无标题文档';
implementation //定义
{$R *.dfm}
begin //新建
richedit1.Lines.Clear; //清除所有文本
richedit1.Modified:=False; //把Modified属性设为False
PathName:=DefaultFileName;
Self.Caption:=DefaultFileName; //把窗口标题设为'无标题'
end;
begin
if opendialog1.Execute then //打开
RichEdit1.Lines.LoadFromFile(Opendialog1.FileName);
end;
begin //保存
SaveDialog1.Filter := '*.txt|*.txt';
if savedialog1.execute then
begin
if extractfileExt(savedialog1.FileName)<>'.txt' then
SaveDialog1.FileName := ChangeFileExt(SaveDialog1.FileName,'.txt');
richedit1.PlainText:=True;
RichEdit1.Lines.SaveToFile(SaveDialog1.FileName);
end;
begin
close; //关闭
end;
begin
RichEdit1.CutToClipboard; //剪切
end;
begin
RichEdit1.CopyToClipboard; //复制
end;
begin
RichEdit1.PasteFromClipboard; //粘贴
end;
begin
RichEdit1.SelectAll; //全选
end;
begin
RichEdit1.ClearSelection; //删除
end;