Ephraim
2008-05-27 15:16:59 UTC
RAD 2007 Teial
I have not created an instance of DataModule2nor aut-=creation, yet no AV
when I press the button TForm1.Button1Click(Sender: TObject);
Is this code treated as a class procedure? Why does it not fail?
TIA
Ephraim
Project Source
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1},
Unit2 in 'Unit2.pas' {DataModule2: TDataModule};
{$R *.res}
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
I create this form
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls{, Project2_TLB};
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
DataModule2.ShowMe('Poor Chelsea');
end;
procedure TForm1.Button2Click(Sender: TObject);
//var
// IDispl: IDisplay;
begin
// IDispl:=CoDisplay.Create;
// IDispl.DisplayMessage('This works')
end;
end.
and this DataModule
unit Unit2;
interface
uses
SysUtils, Classes, Dialogs;
type
TDataModule2 = class(TDataModule)
private
{ Private declarations }
public
{ Public declarations }
procedure ShowMe(const Text: String);
end;
var
DataModule2: TDataModule2;
implementation
{$R *.dfm}
{ TDataModule2 }
procedure TDataModule2.ShowMe(const Text: String);
begin
ShowMessage(Text)
end;
end.
I have not created an instance of DataModule2nor aut-=creation, yet no AV
when I press the button TForm1.Button1Click(Sender: TObject);
Is this code treated as a class procedure? Why does it not fail?
TIA
Ephraim
Project Source
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1},
Unit2 in 'Unit2.pas' {DataModule2: TDataModule};
{$R *.res}
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
I create this form
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls{, Project2_TLB};
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
DataModule2.ShowMe('Poor Chelsea');
end;
procedure TForm1.Button2Click(Sender: TObject);
//var
// IDispl: IDisplay;
begin
// IDispl:=CoDisplay.Create;
// IDispl.DisplayMessage('This works')
end;
end.
and this DataModule
unit Unit2;
interface
uses
SysUtils, Classes, Dialogs;
type
TDataModule2 = class(TDataModule)
private
{ Private declarations }
public
{ Public declarations }
procedure ShowMe(const Text: String);
end;
var
DataModule2: TDataModule2;
implementation
{$R *.dfm}
{ TDataModule2 }
procedure TDataModule2.ShowMe(const Text: String);
begin
ShowMessage(Text)
end;
end.