delphi 10.2 ----memo 的例子 实现基本记事本功能
Posted baili-luoyun
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了delphi 10.2 ----memo 的例子 实现基本记事本功能相关的知识,希望对你有一定的参考价值。
unit Unit2;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TForm2 = class(TForm)
Memo1: TMemo;
SaveDialog1: TSaveDialog;
OpenDialog1: TOpenDialog;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Memo2: TMemo;
Label1: TLabel;
Label2: TLabel;
procedure Edit1Change(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
memo2.Lines.Add(memo1.Lines.Text) ;
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
if memo2.SelLength>0 then
memo2.CutToClipboard;
end;
procedure TForm2.Button3Click(Sender: TObject);
begin
if memo2.SelLength >0 then
memo2.CopyToClipboard;
end;
procedure TForm2.Button4Click(Sender: TObject);
begin
if memo2.SelLength = 0 then
memo2.PasteFromClipboard;
end;
procedure TForm2.Button5Click(Sender: TObject);
begin
if savedialog1.Execute then
memo2.Lines.SaveToFile(savedialog1.FileName);
end;
procedure TForm2.Button6Click(Sender: TObject);
begin
if opendialog1.Execute then
memo2.Lines.LoadFromFile(opendialog1.FileName);
end;
procedure TForm2.Edit1Change(Sender: TObject);
begin
memo1.Lines[0]:=‘aaaaa‘;
end;
以上是关于delphi 10.2 ----memo 的例子 实现基本记事本功能的主要内容,如果未能解决你的问题,请参考以下文章