unit Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, BaseUnit;
type
TForm1 =
class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
MyDevice : TBaseClass;
end;
var
Form1: TForm1;
implementation
uses Unit1;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
MyDevice:=TBaseClass(FindClass('
TDeviceModule1'));
TBaseClass(MyDevice).Create(Self);
end;
end.
BaseUnit:
unit BaseUnit;
interface
uses SysUtils, Classes;
type
TBaseClass =
class (TDataModule)
protected
procedure DoSomethingImportant;
virtual;
abstract;
procedure DoSomethingMoreImportant;
virtual;
abstract;
procedure DoSomethingEvenMoreImportant;
virtual;
abstract;
end;
implementation
end.
Unit1:
unit Unit1;
interface
uses
SysUtils, Classes,Forms,BaseUnit;
type
TDeviceModule1 =
class(TBaseClass)
procedure ShowMsg (Msg:
String);
procedure DataModuleCreate(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
DeviceModule1: TDeviceModule1;
implementation
{$R *.dfm}
procedure TDeviceModule1.DataModuleCreate(Sender: TObject);
begin
ShowMsg('
Create');
end;
procedure TDeviceModule1.ShowMsg (Msg:
String);
begin
Application.MessageBox(PChar(Msg),'
Module1');
end;
initialization
RegisterClasses([TDeviceModule1]);
end.