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

📄 fmmain.pas

📁 多数代码可以直接在Delphi6和Delphi7环境下运行。部分涉及.NET技术内容的代码
💻 PAS
字号:
unit fmMain;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    CheckBox1: TCheckBox;
    RadioButton1: TRadioButton;
    Memo1: TMemo;
    Button2: TButton;
    mmResult: TMemo;
    Button5: TButton;
    Button6: TButton;
    procedure Button5Click(Sender: TObject);
    procedure Button6Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

  TBase = class(TObject)
  private
    iID : Integer;
    dValue : Double;
    sName : String;
  public
    procedure SetName(const sName : String );
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button5Click(Sender: TObject);
var
  aObj : TComponent;
  aButton : TButton;
  alb : TListBox;
  aForm : TForm1;
begin
  aObj := TComponent(TButton.NewInstance);
  aObj.Create(Self);
  aButton := TButton(aObj);
  aButton.Caption := 'I am a Button';

  if (aObj is TListBox) then
  begin
    alb := TListBox(aObj);
    alb.Items.Add('Test');
  end;

  if (aObj is TForm1) then
  begin
    aForm := TForm1(aObj);
    aForm.Caption := 'I am a Form';
    aForm.WindowState := wsNormal;
    aForm.ShowModal;
  end;
end;

procedure TForm1.Button6Click(Sender: TObject);
var
  aBObj : TBase;
  aObj : TObject;
begin
  aObj := TObject(TBase.NewInstance.Create);
  ShowMessage(aObj.ClassName);
  aBObj := TBase(aObj);
  ShowMessage(aBObj.ClassName);
end;

{ TBase }

procedure TBase.SetName(const sName: String);
begin
  Self.sName := sName;
end;

end.

⌨️ 快捷键说明

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