طيباوي ابو علي1
2016-09-13, 10:13
تعامل مع النماذج المستعملة في المشروع
تتطلب بعض المشاريع عدة نماذج
وهذا مثال بسيط لتوضيح ذلك :
----------------------------
الوحدة الاولى
----------------------------
unit untsj;{ djelfa.info/vb }
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;{ djelfa.info/vb }
type
TForm1 = class(TForm)
Button1: TButton;{ djelfa.info/vb }
Button2: TButton;{ djelfa.info/vb }
Button3: TButton;{ djelfa.info/vb }
Button4: TButton;{ djelfa.info/vb }
Button5: TButton;{ djelfa.info/vb }
Button6: TButton;{ djelfa.info/vb }
Button7: TButton;{ djelfa.info/vb }
procedure Button1Click(Sender: TObject);{ djelfa.info/vb }
procedure Button2Click(Sender: TObject);{ djelfa.info/vb }
procedure Button3Click(Sender: TObject);{ djelfa.info/vb }
procedure Button4Click(Sender: TObject);{ djelfa.info/vb }
procedure Button5Click(Sender: TObject);{ djelfa.info/vb }
procedure Button6Click(Sender: TObject);{ djelfa.info/vb }
procedure Button7Click(Sender: TObject);{ djelfa.info/vb }
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;{ djelfa.info/vb }
var
Form1: TForm1;{ djelfa.info/vb }
implementation
// نماذج المستغملة في المشروع
uses Unit2, Unit3, Unit4, Unit5, Unit6, Unit7;{ djelfa.info/vb }
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);{ djelfa.info/vb }
begin
// اظهار النموذج الثاني
Form2.Show;{ djelfa.info/vb }
// اخفاء النموذج الاول
Form1.Hide;{ djelfa.info/vb }
end;{ djelfa.info/vb }
procedure TForm1.Button2Click(Sender: TObject);{ djelfa.info/vb }
begin
// اظهار النموذج الثالث
Form3.Show;{ djelfa.info/vb }
// اخفاء النموذج الاول
Form1.Hide;{ djelfa.info/vb }
end;{ djelfa.info/vb }
procedure TForm1.Button3Click(Sender: TObject);{ djelfa.info/vb }
begin
// اظهار النموذج الرابع
Form4.Show;{ djelfa.info/vb }
// اخفاء النموذج الاول
Form1.Hide;{ djelfa.info/vb }
end;{ djelfa.info/vb }
procedure TForm1.Button4Click(Sender: TObject);{ djelfa.info/vb }
begin
// اظهار النموذج الخامس
Form5.Show;{ djelfa.info/vb }
// اخفاء النموذج الاول
Form1.Hide;{ djelfa.info/vb }
end;{ djelfa.info/vb }
procedure TForm1.Button5Click(Sender: TObject);{ djelfa.info/vb }
begin
// اظهار النموذج السادس
Form6.Show;{ djelfa.info/vb }
// اخفاء النموذج الاول
Form1.Hide;{ djelfa.info/vb }
end;{ djelfa.info/vb }
procedure TForm1.Button6Click(Sender: TObject);{ djelfa.info/vb }
begin
// اظهار النموذج السابع
Form7.Show;{ djelfa.info/vb }
// اخفاء النموذج الاول
Form1.Hide;{ djelfa.info/vb }
end;{ djelfa.info/vb }
procedure TForm1.Button7Click(Sender: TObject);{ djelfa.info/vb }
begin
// اغلاق البرنامج
Close;{ djelfa.info/vb }
end;{ djelfa.info/vb }
end.
-----------------------------
الوحدة الثانية
-----------------------------
unit Unit2;{ djelfa.info/vb }
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;{ djelfa.info/vb }
type
TForm2 = class(TForm)
Button1: TButton;{ djelfa.info/vb }
procedure FormClose(Sender: TObject;{ djelfa.info/vb } var Action: TCloseAction);{ djelfa.info/vb }
procedure Button1Click(Sender: TObject);{ djelfa.info/vb }
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;{ djelfa.info/vb }
var
Form2: TForm2;{ djelfa.info/vb }
implementation
uses untsj;{ djelfa.info/vb }
{$R *.DFM}
procedure TForm2.FormClose(Sender: TObject;{ djelfa.info/vb } var Action: TCloseAction);{ djelfa.info/vb }
begin
// اظهار النموذج الاول
Form1.Show;{ djelfa.info/vb }
end;{ djelfa.info/vb }
procedure TForm2.Button1Click(Sender: TObject);{ djelfa.info/vb }
begin
// اغلاق النموذجالثاني
Form2.Close;{ djelfa.info/vb }
end;{ djelfa.info/vb }
end.
-------------------------------
الوحدة الثالثة
-------------------------------
unit Unit3;{ djelfa.info/vb }
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;{ djelfa.info/vb }
type
TForm3 = class(TForm)
Button1: TButton;{ djelfa.info/vb }
procedure FormClose(Sender: TObject;{ djelfa.info/vb } var Action: TCloseAction);{ djelfa.info/vb }
procedure Button1Click(Sender: TObject);{ djelfa.info/vb }
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;{ djelfa.info/vb }
var
Form3: TForm3;{ djelfa.info/vb }
implementation
uses untsj;{ djelfa.info/vb }
{$R *.DFM}
procedure TForm3.FormClose(Sender: TObject;{ djelfa.info/vb } var Action: TCloseAction);{ djelfa.info/vb }
begin
// اظهار النموذج الاول
Form1.Show;{ djelfa.info/vb }
end;{ djelfa.info/vb }
procedure TForm3.Button1Click(Sender: TObject);{ djelfa.info/vb }
begin
// اغلاق النموذج الثالث
Form3.Close;{ djelfa.info/vb }
end;{ djelfa.info/vb }
end.
---------------------------------
الوحدة الرابعة
---------------------------------
unit Unit4;{ djelfa.info/vb }
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;{ djelfa.info/vb }
type
TForm4 = class(TForm)
Button1: TButton;{ djelfa.info/vb }
procedure FormClose(Sender: TObject;{ djelfa.info/vb } var Action: TCloseAction);{ djelfa.info/vb }
procedure Button1Click(Sender: TObject);{ djelfa.info/vb }
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;{ djelfa.info/vb }
var
Form4: TForm4;{ djelfa.info/vb }
implementation
uses untsj;{ djelfa.info/vb }
{$R *.DFM}
procedure TForm4.FormClose(Sender: TObject;{ djelfa.info/vb } var Action: TCloseAction);{ djelfa.info/vb }
begin
// اظهار النموذج الاول
Form1.Show;{ djelfa.info/vb }
end;{ djelfa.info/vb }
procedure TForm4.Button1Click(Sender: TObject);{ djelfa.info/vb }
begin
// اغلاق النموذج الرابع
Form4.Close;{ djelfa.info/vb }
end;{ djelfa.info/vb }
end.
----------------------------
الوحدة الخامسة
----------------------------
unit Unit5;{ djelfa.info/vb }
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;{ djelfa.info/vb }
type
TForm5 = class(TForm)
Button1: TButton;{ djelfa.info/vb }
procedure FormClose(Sender: TObject;{ djelfa.info/vb } var Action: TCloseAction);{ djelfa.info/vb }
procedure Button1Click(Sender: TObject);{ djelfa.info/vb }
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;{ djelfa.info/vb }
var
Form5: TForm5;{ djelfa.info/vb }
implementation
uses untsj;{ djelfa.info/vb }
{$R *.DFM}
procedure TForm5.FormClose(Sender: TObject;{ djelfa.info/vb } var Action: TCloseAction);{ djelfa.info/vb }
begin
// اظهار النموذج الاول
Form1.Show;{ djelfa.info/vb }
end;{ djelfa.info/vb }
procedure TForm5.Button1Click(Sender: TObject);{ djelfa.info/vb }
begin
// اغلاق النموذج الخامس
Form5.Close;{ djelfa.info/vb }
end;{ djelfa.info/vb }
end.
-------------------------------------
الوحدة السادسة
-------------------------------------
unit Unit6;{ djelfa.info/vb }
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;{ djelfa.info/vb }
type
TForm6 = class(TForm)
Button1: TButton;{ djelfa.info/vb }
procedure FormClose(Sender: TObject;{ djelfa.info/vb } var Action: TCloseAction);{ djelfa.info/vb }
procedure Button1Click(Sender: TObject);{ djelfa.info/vb }
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;{ djelfa.info/vb }
var
Form6: TForm6;{ djelfa.info/vb }
implementation
uses untsj;{ djelfa.info/vb }
{$R *.DFM}
procedure TForm6.FormClose(Sender: TObject;{ djelfa.info/vb } var Action: TCloseAction);{ djelfa.info/vb }
begin
// اظهار النموذج الاول
Form1.Show;{ djelfa.info/vb }
end;{ djelfa.info/vb }
procedure TForm6.Button1Click(Sender: TObject);{ djelfa.info/vb }
begin
// اغلاق النموذج السادس
Form6.Close;{ djelfa.info/vb }
end;{ djelfa.info/vb }
end.
----------------------------
الوحدة السابعة
----------------------------
unit Unit7;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm7 = class(TForm)
Button1: TButton;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button1Click(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form7: TForm7;
implementation
uses untsj;
{$R *.DFM}
procedure TForm7.FormClose(Sender: TObject; var Action: TCloseAction);
begin
// اظهار النموذج الاول
Form1.Show;
end;
procedure TForm7.Button1Click(Sender: TObject);
begin
// اغلاق النموذج السابع
Form7.Close;
end;
end.
تتطلب بعض المشاريع عدة نماذج
وهذا مثال بسيط لتوضيح ذلك :
----------------------------
الوحدة الاولى
----------------------------
unit untsj;{ djelfa.info/vb }
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;{ djelfa.info/vb }
type
TForm1 = class(TForm)
Button1: TButton;{ djelfa.info/vb }
Button2: TButton;{ djelfa.info/vb }
Button3: TButton;{ djelfa.info/vb }
Button4: TButton;{ djelfa.info/vb }
Button5: TButton;{ djelfa.info/vb }
Button6: TButton;{ djelfa.info/vb }
Button7: TButton;{ djelfa.info/vb }
procedure Button1Click(Sender: TObject);{ djelfa.info/vb }
procedure Button2Click(Sender: TObject);{ djelfa.info/vb }
procedure Button3Click(Sender: TObject);{ djelfa.info/vb }
procedure Button4Click(Sender: TObject);{ djelfa.info/vb }
procedure Button5Click(Sender: TObject);{ djelfa.info/vb }
procedure Button6Click(Sender: TObject);{ djelfa.info/vb }
procedure Button7Click(Sender: TObject);{ djelfa.info/vb }
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;{ djelfa.info/vb }
var
Form1: TForm1;{ djelfa.info/vb }
implementation
// نماذج المستغملة في المشروع
uses Unit2, Unit3, Unit4, Unit5, Unit6, Unit7;{ djelfa.info/vb }
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);{ djelfa.info/vb }
begin
// اظهار النموذج الثاني
Form2.Show;{ djelfa.info/vb }
// اخفاء النموذج الاول
Form1.Hide;{ djelfa.info/vb }
end;{ djelfa.info/vb }
procedure TForm1.Button2Click(Sender: TObject);{ djelfa.info/vb }
begin
// اظهار النموذج الثالث
Form3.Show;{ djelfa.info/vb }
// اخفاء النموذج الاول
Form1.Hide;{ djelfa.info/vb }
end;{ djelfa.info/vb }
procedure TForm1.Button3Click(Sender: TObject);{ djelfa.info/vb }
begin
// اظهار النموذج الرابع
Form4.Show;{ djelfa.info/vb }
// اخفاء النموذج الاول
Form1.Hide;{ djelfa.info/vb }
end;{ djelfa.info/vb }
procedure TForm1.Button4Click(Sender: TObject);{ djelfa.info/vb }
begin
// اظهار النموذج الخامس
Form5.Show;{ djelfa.info/vb }
// اخفاء النموذج الاول
Form1.Hide;{ djelfa.info/vb }
end;{ djelfa.info/vb }
procedure TForm1.Button5Click(Sender: TObject);{ djelfa.info/vb }
begin
// اظهار النموذج السادس
Form6.Show;{ djelfa.info/vb }
// اخفاء النموذج الاول
Form1.Hide;{ djelfa.info/vb }
end;{ djelfa.info/vb }
procedure TForm1.Button6Click(Sender: TObject);{ djelfa.info/vb }
begin
// اظهار النموذج السابع
Form7.Show;{ djelfa.info/vb }
// اخفاء النموذج الاول
Form1.Hide;{ djelfa.info/vb }
end;{ djelfa.info/vb }
procedure TForm1.Button7Click(Sender: TObject);{ djelfa.info/vb }
begin
// اغلاق البرنامج
Close;{ djelfa.info/vb }
end;{ djelfa.info/vb }
end.
-----------------------------
الوحدة الثانية
-----------------------------
unit Unit2;{ djelfa.info/vb }
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;{ djelfa.info/vb }
type
TForm2 = class(TForm)
Button1: TButton;{ djelfa.info/vb }
procedure FormClose(Sender: TObject;{ djelfa.info/vb } var Action: TCloseAction);{ djelfa.info/vb }
procedure Button1Click(Sender: TObject);{ djelfa.info/vb }
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;{ djelfa.info/vb }
var
Form2: TForm2;{ djelfa.info/vb }
implementation
uses untsj;{ djelfa.info/vb }
{$R *.DFM}
procedure TForm2.FormClose(Sender: TObject;{ djelfa.info/vb } var Action: TCloseAction);{ djelfa.info/vb }
begin
// اظهار النموذج الاول
Form1.Show;{ djelfa.info/vb }
end;{ djelfa.info/vb }
procedure TForm2.Button1Click(Sender: TObject);{ djelfa.info/vb }
begin
// اغلاق النموذجالثاني
Form2.Close;{ djelfa.info/vb }
end;{ djelfa.info/vb }
end.
-------------------------------
الوحدة الثالثة
-------------------------------
unit Unit3;{ djelfa.info/vb }
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;{ djelfa.info/vb }
type
TForm3 = class(TForm)
Button1: TButton;{ djelfa.info/vb }
procedure FormClose(Sender: TObject;{ djelfa.info/vb } var Action: TCloseAction);{ djelfa.info/vb }
procedure Button1Click(Sender: TObject);{ djelfa.info/vb }
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;{ djelfa.info/vb }
var
Form3: TForm3;{ djelfa.info/vb }
implementation
uses untsj;{ djelfa.info/vb }
{$R *.DFM}
procedure TForm3.FormClose(Sender: TObject;{ djelfa.info/vb } var Action: TCloseAction);{ djelfa.info/vb }
begin
// اظهار النموذج الاول
Form1.Show;{ djelfa.info/vb }
end;{ djelfa.info/vb }
procedure TForm3.Button1Click(Sender: TObject);{ djelfa.info/vb }
begin
// اغلاق النموذج الثالث
Form3.Close;{ djelfa.info/vb }
end;{ djelfa.info/vb }
end.
---------------------------------
الوحدة الرابعة
---------------------------------
unit Unit4;{ djelfa.info/vb }
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;{ djelfa.info/vb }
type
TForm4 = class(TForm)
Button1: TButton;{ djelfa.info/vb }
procedure FormClose(Sender: TObject;{ djelfa.info/vb } var Action: TCloseAction);{ djelfa.info/vb }
procedure Button1Click(Sender: TObject);{ djelfa.info/vb }
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;{ djelfa.info/vb }
var
Form4: TForm4;{ djelfa.info/vb }
implementation
uses untsj;{ djelfa.info/vb }
{$R *.DFM}
procedure TForm4.FormClose(Sender: TObject;{ djelfa.info/vb } var Action: TCloseAction);{ djelfa.info/vb }
begin
// اظهار النموذج الاول
Form1.Show;{ djelfa.info/vb }
end;{ djelfa.info/vb }
procedure TForm4.Button1Click(Sender: TObject);{ djelfa.info/vb }
begin
// اغلاق النموذج الرابع
Form4.Close;{ djelfa.info/vb }
end;{ djelfa.info/vb }
end.
----------------------------
الوحدة الخامسة
----------------------------
unit Unit5;{ djelfa.info/vb }
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;{ djelfa.info/vb }
type
TForm5 = class(TForm)
Button1: TButton;{ djelfa.info/vb }
procedure FormClose(Sender: TObject;{ djelfa.info/vb } var Action: TCloseAction);{ djelfa.info/vb }
procedure Button1Click(Sender: TObject);{ djelfa.info/vb }
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;{ djelfa.info/vb }
var
Form5: TForm5;{ djelfa.info/vb }
implementation
uses untsj;{ djelfa.info/vb }
{$R *.DFM}
procedure TForm5.FormClose(Sender: TObject;{ djelfa.info/vb } var Action: TCloseAction);{ djelfa.info/vb }
begin
// اظهار النموذج الاول
Form1.Show;{ djelfa.info/vb }
end;{ djelfa.info/vb }
procedure TForm5.Button1Click(Sender: TObject);{ djelfa.info/vb }
begin
// اغلاق النموذج الخامس
Form5.Close;{ djelfa.info/vb }
end;{ djelfa.info/vb }
end.
-------------------------------------
الوحدة السادسة
-------------------------------------
unit Unit6;{ djelfa.info/vb }
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;{ djelfa.info/vb }
type
TForm6 = class(TForm)
Button1: TButton;{ djelfa.info/vb }
procedure FormClose(Sender: TObject;{ djelfa.info/vb } var Action: TCloseAction);{ djelfa.info/vb }
procedure Button1Click(Sender: TObject);{ djelfa.info/vb }
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;{ djelfa.info/vb }
var
Form6: TForm6;{ djelfa.info/vb }
implementation
uses untsj;{ djelfa.info/vb }
{$R *.DFM}
procedure TForm6.FormClose(Sender: TObject;{ djelfa.info/vb } var Action: TCloseAction);{ djelfa.info/vb }
begin
// اظهار النموذج الاول
Form1.Show;{ djelfa.info/vb }
end;{ djelfa.info/vb }
procedure TForm6.Button1Click(Sender: TObject);{ djelfa.info/vb }
begin
// اغلاق النموذج السادس
Form6.Close;{ djelfa.info/vb }
end;{ djelfa.info/vb }
end.
----------------------------
الوحدة السابعة
----------------------------
unit Unit7;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm7 = class(TForm)
Button1: TButton;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button1Click(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form7: TForm7;
implementation
uses untsj;
{$R *.DFM}
procedure TForm7.FormClose(Sender: TObject; var Action: TCloseAction);
begin
// اظهار النموذج الاول
Form1.Show;
end;
procedure TForm7.Button1Click(Sender: TObject);
begin
// اغلاق النموذج السابع
Form7.Close;
end;
end.