I have two VCL Forms: Form1 in Unit1 and Form2 in Unit2.
I also added another Unit into the Project, the Unit3.
In the Unit3, the Unit1 and Unit2 were added in the uses list. I have managed to create a class that may manipulate other units (Unit1 & Unit2):
unit Unit3;
interface
uses
Vcl.Forms, Unit1, Unit2;
type
Tmain = class
private
procedure openForm1;
procedure openForm2;
end;
var
Form1: TForm1;
Form2: TForm2;
implementation
procedure Tmain.openForm1;
begin
//I will create code to open Form1 soon
end;
procedure Tmain.openForm2;
begin
//I will create code to open Form2 soon
end;
end.
How can I run (or create properly) a Shared Code Unit for managing the Form1 & Form2 if the Project1's Source Code seemed not to run my Shared Code Unit (Unit3)?
program Project1;
uses
Vcl.Forms,
Unit1 in 'Unit1.pas' {Form1},
Unit2 in 'Unit2.pas' {Form2},
Unit3 in 'Unit3.pas';
{$R *.res}
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TForm1, Form1);
Application.CreateForm(TForm2, Form2);
Application.Run;
end.
I am trying these algorithms to avoid circular references as my level of understanding through Lieven Keersmaekers's answer on How to manage circular references in delphi units?