⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.pas

📁 DELPHI经典程序
💻 PAS
字号:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ActnList, StdCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Button1: TButton;
    ActionList1: TActionList;
    Action1: TAction;
    Button2: TButton;
    Action2: TAction;
    Label3: TLabel;
    Label1: TLabel;
    Label2: TLabel;
    procedure Action1Execute(Sender: TObject);
    procedure Action1Update(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Action2Update(Sender: TObject);
    procedure Action2Execute(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}
var
  a:Int64;

procedure TForm1.FormCreate(Sender: TObject);
  var
   X:Integer;
   ActionsStr:String;
begin
  a := 0;  // 为变数作初始化

  ActionsStr:='';
  for X:=0 to ActionList1.ActionCount-1 do
   ActionsStr:=ActionsStr+IntToStr(ActionList1.Actions[X].Index)
               +':'+ActionList1.Actions[X].Name+#13;

  Label1.Caption:='ActionList1 共有 '
                 +IntToStr(ActionList1.ActionCount)+' 个 Action'+#13
                 +ActionsStr;
end;

procedure TForm1.Action1Execute(Sender: TObject);
begin
    ShowMessage('Button1 is Clicked');
end;

procedure TForm1.Action1Update(Sender: TObject);
begin
   Label2.Caption:= 'Action1 的 OnUpdate 执行中...';
   Label3.Caption := IntToStr( a );
   a := a+1;
   Button1.Enabled := Edit1.Modified;
end;

procedure TForm1.Action2Update(Sender: TObject);
begin
   if Edit1.SelLength > 0 then
     Button2.Enabled := True
   else
     Button2.Enabled := False;
end;

procedure TForm1.Action2Execute(Sender: TObject);
begin
  Edit1.Text := Edit1.SelText;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -