Цель лабораторной работы: Научиться подключать инструментальную панель, изучить основные свойства и типы кнопок и использование их для управления вычислительным процессом.
Задание: Разработать программу, в которой предусмотреть управление вычислительным процессом с помощью кнопок, расположенных на инструментальной панели. Задание использовать из л.р.№8.
Листинг программы:
Текст главного модуля:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, TeEngine, Series, ExtCtrls, TeeProcs, Chart, StdCtrls, ComCtrls,
ToolWin, ImgList, Buttons;
type
TForm1 = class(TForm)
Panel1: TPanel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
ImageList1: TImageList;
ToolBar1: TToolBar;
run: TToolButton;
BXmin: TToolButton;
BXmax: TToolButton;
BYmin: TToolButton;
BYmax: TToolButton;
BH: TToolButton;
BY: TToolButton;
BZ: TToolButton;
Label5: TLabel;
Label6: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
BitBtn1: TBitBtn;
Chart1: TChart;
Series1: TLineSeries;
Image1: TImage;
procedure FormCreate(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure runClick(Sender: TObject);
procedure BXminClick(Sender: TObject);
procedure BXmaxClick(Sender: TObject);
procedure BYminClick(Sender: TObject);
procedure BYmaxClick(Sender: TObject);
procedure BHClick(Sender: TObject);
procedure BYClick(Sender: TObject);
procedure BZClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Xmin,Xmax,Ymin,Ymax,y,z,h:extended;
implementation
uses Unit2, Unit3, Unit4, Unit5, Unit6, Unit7, Unit8;
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
ToolBar1.Images:=ImageList1;
Xmin := 1;
Xmax := 10;
Ymin := 0;
Ymax := 20;
y := 2;
z := 0.8;
h := 0.4;
Label5.Caption:='1';
Label6.Caption:='10';
Label10.Caption:='0';
Label11.Caption:='20';
Label12.Caption:='2';
Label13.Caption:='0.8';
Label14.Caption:='0.4';
BitBtn1Click(Sender);
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var
x,b : extended;
begin
Series1.Clear;
x := Xmin;
Chart1.BottomAxis.Automatic := False;
Chart1.BottomAxis.Maximum := Xmax;
Chart1.BottomAxis.Minimum := Xmin;
Chart1.LeftAxis.Automatic := False;
Chart1.LeftAxis.Minimum := Ymin;
Chart1.LeftAxis.Maximum := Ymax;
Repeat
b := Exp(-x*ln(2))* Sqrt((x+Exp(1/4*ln(Abs(y)))))* Exp(1/3*ln(Exp((x-1/sin(z)))));
Series1.AddXY(x,b,'',clTeeColor);
x := x+h;
Until (x>Xmax);
end;
procedure TForm1.runClick(Sender: TObject);
begin
BitBtn1Click(Sender);
end;
procedure TForm1.BXminClick(Sender: TObject);
begin
Form2.Visible:=True;
end;
procedure TForm1.BXmaxClick(Sender: TObject);
begin
Form3.Visible:=True;
end;
procedure TForm1.BYminClick(Sender: TObject);
begin
Form4.Visible:=True;
end;
procedure TForm1.BYmaxClick(Sender: TObject);
begin
Form5.Visible:=True;
end;
procedure TForm1.BHClick(Sender: TObject);
begin
Form6.Visible:=True;
end;
procedure TForm1.BYClick(Sender: TObject);
begin
Form7.Visible:=True;
end;
procedure TForm1.BZClick(Sender: TObject);
begin
Form8.Visible:=True;
end;
end.
Текст остальных модулей:
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;
type
TForm2 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
BitBtn1: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses Unit1;
{$R *.dfm}
procedure TForm2.BitBtn1Click(Sender: TObject);
begin
Xmin:=StrToFloat(Edit1.Text);
Form1.Label5.Caption:= FloatToStr(Xmin);
Form2.Close;
end;
procedure TForm2.FormCreate(Sender: TObject);
begin
Edit1.Text:= FloatToStr(Xmin);
end;
end.
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;
type
TForm3 = class(TForm)
Edit1: TEdit;
Label1: TLabel;
BitBtn1: TBitBtn;
procedure FormCreate(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
uses Unit1 ;
{$R *.dfm}
procedure TForm3.FormCreate(Sender: TObject);
begin
Edit1.Text:= FloatToStr(Xmax);
end;
procedure TForm3.BitBtn1Click(Sender: TObject);
begin
Xmax:=StrToFloat(Edit1.Text);
Form1.Label6.Caption:= FloatToStr(Xmax);
Form3.Close;
end;
end.
unit Unit4;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;
type
TForm4 = class(TForm)
BitBtn1: TBitBtn;
Label1: TLabel;
Edit1: TEdit;
procedure FormCreate(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form4: TForm4;
implementation
uses Unit1;
{$R *.dfm}
procedure TForm4.FormCreate(Sender: TObject);
begin
Edit1.Text:= FloatToStr(Ymin);
end;
procedure TForm4.BitBtn1Click(Sender: TObject);
begin
Ymin:=StrToFloat(Edit1.Text);
Form1.Label10.Caption:= FloatToStr(Ymin);
Form4.Close;
end;
end.
unit Unit5;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;
type
TForm5 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
BitBtn1: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form5: TForm5;
implementation
uses unit1;
{$R *.dfm}
procedure TForm5.BitBtn1Click(Sender: TObject);
begin
Ymax:=StrToFloat(Edit1.Text);
Form1.Label11.Caption:= FloatToStr(Ymax);
Form5.Close;
end;
procedure TForm5.FormCreate(Sender: TObject);
begin
Edit1.Text:= FloatToStr(Ymax);
end;
end.
unit Unit5;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;
type
TForm5 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
BitBtn1: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form5: TForm5;
implementation
uses unit1;
{$R *.dfm}
procedure TForm5.BitBtn1Click(Sender: TObject);
begin
Ymax:=StrToFloat(Edit1.Text);
Form1.Label11.Caption:= FloatToStr(Ymax);
Form5.Close;
end;
procedure TForm5.FormCreate(Sender: TObject);
begin
Edit1.Text:= FloatToStr(Ymax);
end;
end.
unit Unit7;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;
type
TForm7 = class(TForm)
BitBtn1: TBitBtn;
Label1: TLabel;
Edit1: TEdit;
procedure FormCreate(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form7: TForm7;
implementation
uses Unit1;
{$R *.dfm}
procedure TForm7.FormCreate(Sender: TObject);
begin
Edit1.Text:= FloatToStr(y);
end;
procedure TForm7.BitBtn1Click(Sender: TObject);
begin
y:=StrToFloat(Edit1.Text);
Form1.Label13.Caption:= FloatToStr(y);
Form7.Close;
end;
end.
unit Unit8;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;
type
TForm8 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
BitBtn1: TBitBtn;
procedure FormCreate(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form8: TForm8;
implementation
uses Unit1;
{$R *.dfm}
procedure TForm8.FormCreate(Sender: TObject);
begin
Edit1.Text:= FloatToStr(z);
end;
procedure TForm8.BitBtn1Click(Sender: TObject);
begin
z:=StrToFloat(Edit1.Text);
Form1.Label14.Caption:= FloatToStr(z);
Form8.Close;
end;
end.
Результат выполнения программы:
Выводы: научились подключать инструментальную панель, изучили основные свойства и типы кнопок и использование их для управления вычислительным процессом.