program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1},
Unit2 in 'Unit2.pas' {Form2};
{$R *.RES}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
/////////////////////////////////////////////
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
s:string;
begin
s:='1234';
form2:=TForm2.Create(self,s);
form2.showModal;
form2.free;
showmessage(s);// '567890'
end;
end.
//////////////////////////////////////
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm2 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
pS
ointer;
{ Private declarations }
public
constructor Create(AOwner: TComponent
var iReturnValue: String);reintroduce;
{ Public declarations }
end;
var
Form2: TForm2;
implementation
{$R *.DFM}
{ TForm2 }
constructor TForm2.Create(AOwner: TComponent
var iReturnValue: String);
begin
inherited create(AOwner);
pS:=@iReturnValue;
end;
procedure TForm2.Button1Click(Sender: TObject);
begin
string(pS^):='567890';
end;
end.