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

📄 fmidservicemain.pas

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

interface

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

type
  TForm2 = class(TForm)
    Button1: TButton;
    mmInfos: TMemo;
    Button2: TButton;
    Button3: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure AppMsg(const sMsg : String);
  end;

  TForm3 = class(TForm2)
  end;

var
  Form2: TForm2;

implementation

uses uClasses;

{$R *.dfm}

procedure TForm2.AppMsg(const sMsg: String);
begin
  mmInfos.Lines.Add(sMsg);
end;

procedure TForm2.Button1Click(Sender: TObject);
var
  aBase : TBase;
  adr1 : TDerived1;
  adr2 : TDerived2;
begin
  aBase := TBase.Create;
  adr1 := TDerived1.Create;
  adr2 := TDerived2.Create;
  try
    AppMsg('InstanceSize :' + IntToStr(aBase.InstanceSize));
    AppMsg('InstanceSize :' + IntToStr(adr1.InstanceSize));
    AppMsg('InstanceSize :' + IntToStr(adr2.InstanceSize));
  finally
    FreeAndNil(adr2);
    FreeAndNil(adr1);
    FreeAndNil(aBase);
  end;
end;

procedure TForm2.Button2Click(Sender: TObject);
var
  aBase : TBase;
  adr2 : TDerived2;
begin
  aBase := TBase.Create;
  adr2 := TDerived2.Create;
  try
    if (adr2.InheritsFrom(TBase)) then
      AppMsg('TDerived2 is inherited from TBase')
    else
      AppMsg('TDerived2 is not inherited from TBase')
  finally
    FreeAndNil(adr2);
    FreeAndNil(aBase);
  end;
end;

procedure TForm2.Button3Click(Sender: TObject);
var
  ac : TClass;
  f3 : TForm3;
begin
  f3 := TForm3.Create(Self);
  try
    ac := f3.ClassParent;
    if (ac = TForm2) then
      AppMsg('TForm2 is the parent class of TForm3')
    else
      AppMsg('TForm2 is not the parent class of TForm3')
  finally
    FreeAndNil(f3);
  end;
end;

end.

⌨️ 快捷键说明

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