with.pas

来自「FastScript 1.94 Full Source」· PAS 代码 · 共 50 行

PAS
50
字号
{**************************}
{ FastScript v1.0          }
{ With operator demo       }
{**************************}

var
  f: TForm;
  b: TButton;

procedure ButtonClick(Sender: TButton);
begin
  ShowMessage(Sender.Name);
  f.ModalResult := mrOk;
end;

// there is no necessary to use all parameters 
// in the event handlers
// because no type checking is performed
procedure ButtonMouseMove(Sender: TButton);
begin
  b.Caption := 'moved over';
end;

begin
  f := TForm.Create(nil);
  with f do
  begin
    Caption := 'Test it!';
    BorderStyle := bsDialog;
    Position := poScreenCenter;
  end;

  b := TButton.Create(f);
  with b do
  begin
    Name := 'Button1';
    Parent := f;
    SetBounds(10, 10, 75, 25);
    Caption := 'Test';

    OnClick := @ButtonClick; { same as b.OnClick := 'ButtonClick' }
    OnMouseMove := @ButtonMouseMove;
  end;

  with f do
  begin
    ShowModal;
    Free;
  end;
end.

⌨️ 快捷键说明

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