Автор: Пользователь скрыл имя, 20 Декабря 2010 в 21:03, контрольная работа
Простейшая программа в среде Delphi.
Цель работы: Научиться конструировать главную форму программы простейшими стандартными компонентами.
Постановка задачи:
1.Создать главную форму и присвоить ей имя, соответствующее лабораторной работе.
2.Сконструировать простейший калькулятор.
3.Написать обработчики, реализующие основные арифметические действия калькулятора.
4.Изучить структуру Unit главной формы.
Red.Free;
end;
end.
unit Unit3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,
ExtCtrls, StdCtrls, Buttons;
type
TForm3 = class(TForm)
BitBtn1: TBitBtn;
Shape1: TShape;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
BitBtn4: TBitBtn;
BitBtn5: TBitBtn;
BitBtn6: TBitBtn;
Shape2: TShape;
Shape3: TShape;
Shape4: TShape;
Shape5: TShape;
Shape6: TShape;
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
procedure BitBtn4Click(Sender: TObject);
procedure BitBtn5Click(Sender: TObject);
procedure BitBtn6Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3:
TForm3;
implementation
{$R *.dfm}
procedure TForm3.BitBtn1Click(Sender: TObject);
begin
Shape1.Visible:=true;
Shape1.Shape:=stCircle;
Shape2.Visible:=false;
Shape3.Visible:=false;
Shape4.Visible:=false;
Shape5.Visible:=false;
Shape6.Visible:=false;
end;
procedure TForm3.BitBtn2Click(Sender: TObject);
begin
Shape2.Visible:=true;
Shape2.Shape:=stEllipse;
Shape1.Visible:=false;
Shape3.Visible:=false;
Shape4.Visible:=false;
Shape5.Visible:=false;
Shape6.Visible:=false;
end;
procedure TForm3.BitBtn3Click(Sender: TObject);
begin
Shape3.Visible:=true;
Shape3.Shape:=stRectangle;
Shape1.Visible:=false;
Shape2.Visible:=false;
Shape4.Visible:=false;
Shape5.Visible:=false;
Shape6.Visible:=false;
end;
procedure TForm3.BitBtn4Click(Sender: TObject);
begin
Shape4.Visible:=true;
Shape4.Shape:=stRoundRect;
Shape1.Visible:=false;
Shape2.Visible:=false;
Shape3.Visible:=false;
Shape5.Visible:=false;
Shape6.Visible:=false;
end;
procedure TForm3.BitBtn5Click(Sender: TObject);
begin
Shape5.Visible:=true;
Shape5.Shape:=stRoundSquare;
Shape1.Visible:=false;
Shape2.Visible:=false;
Shape3.Visible:=false;
Shape4.Visible:=false;
Shape6.Visible:=false;
end;
procedure TForm3.BitBtn6Click(Sender: TObject);
begin
Shape6.Visible:=true;
Shape6.Shape:=stSquare;
Shape1.Visible:=false;
Shape2.Visible:=false;
Shape3.Visible:=false;
Shape4.Visible:=false;
Shape5.Visible:=false;
end;
procedure TForm3.FormCreate(Sender: TObject);
begin
Shape1.Visible:=true;
Shape1.Shape:=stCircle;
Shape2.Visible:=false;
Shape3.Visible:=false;
Shape4.Visible:=false;
Shape5.Visible:=false;
Shape6.Visible:=false;
end;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,
StdCtrls, Buttons, ExtCtrls, Menus, ExtDlgs;
type
TRed = class(TForm)
Image1: TImage;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
BitBtn4: TBitBtn;
BitBtn5: TBitBtn;
BitBtn6: TBitBtn;
BitBtn8: TBitBtn;
Shape1: TShape;
Shape2: TShape;
Bevel1: TBevel;
ColorDialog1: TColorDialog;
MainMenu1: TMainMenu;
Timer1: TTimer;
Edit3: TEdit;
Edit4: TEdit;
Bevel2: TBevel;
Edit5: TEdit;
Edit6: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Edit7: TEdit;
Label5: TLabel;
Button1: TButton;
Label6: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Label7: TLabel;
Label8: TLabel;
Edit8: TEdit;
Edit9: TEdit;
Label9: TLabel;
Bevel3: TBevel;
Button2: TButton;
Bevel4: TBevel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Edit10: TEdit;
Edit11: TEdit;
Edit12: TEdit;
Edit13: TEdit;
Button3: TButton;
Bevel5: TBevel;
Label14: TLabel;
Label15: TLabel;
Label16: TLabel;
Label17: TLabel;
Edit14: TEdit;
Edit15: TEdit;
Edit16: TEdit;
Edit17: TEdit;
Button4: TButton;
OpenPictureDialog1: TOpenPictureDialog;
SavePictureDialog1: TSavePictureDialog;
File1: TMenuItem;
Exit1: TMenuItem;
N4: TMenuItem;
Save1: TMenuItem;
New1: TMenuItem;
N1: TMenuItem;
BitBtn7: TBitBtn;
procedure polegon();
procedure duga(x1,x2,y1,y2,r: integer);
procedure ellips(xc,yc,enx,eny:integer);
procedure krug(xc,yc, x2, y2:integer);
procedure line(bx:TBitMap;x1, y1, x2, y2:integer);
procedure zakrash(x,y: integer);
procedure FormCreate(Sender: TObject);
procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure BitBtn5Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Shape1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure BitBtn3Click(Sender: TObject);
procedure BitBtn4Click(Sender: TObject);
procedure BitBtn6Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure BitBtn8Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure Save1Click(Sender: TObject);
procedure Exit1Click(Sender: TObject);
procedure New1Click(Sender: TObject);
procedure BitBtn7Click(Sender: TObject);
private
{ Private declarations }
public
bp:TBitMap;
b1:TBitMap;
b2:TBitMap;
{ Public declarations }
end;
var
Red: TRed;
flag,lin: integer;
X1,Y1: integer;
Xp,Yp,Xp1,Yp1: integer;
ClrFon:
TColor;
implementation
{$R *.dfm}
procedure TRed.polegon();
var a,i,j:integer;
x1,x2:integer;
begin
line(b2,Xp,Yp,Xp1,Yp1);
line(b1,Xp,Yp,Xp1,Yp1);
line(bp,Xp,Yp,Xp1,Yp1);
b2.Canvas.CopyMode:=cmSrcCopy;
b2.Canvas.CopyRect(Rect(0,0,
Image1.Canvas.CopyMode:=
Image1.Canvas.CopyRect(Rect(0,
for j:=0 to 299 do
begin
a:=0;
for i:=0 to 499 do
begin
if (b2.Canvas.Pixels[i,j]<>RGB(
(b2.Canvas.Pixels[i-1,j]=b2.
if b2.Canvas.Pixels[i,j]<>RGB(
begin
if a=0 then begin a:=1; x1:=i; end else begin a:=2; x2:=i; end;
if a=2 then begin
Информация о работе Контрольная работа по "Программирование"