2 Результат работы программы

Рисунок 1- Внешний вид программы
3 Листинг программы
Файл Unit1.h
//---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Menus.hpp>
#include <ExtCtrls.hpp>
#include <Dialogs.hpp>
#include <ExtDlgs.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TGroupBox *GroupBox1;
TRadioButton *RadioButton4;
TRadioButton *RadioButton5;
TRadioButton *RadioButton6;
TOpenPictureDialog *OpenPictureDialog1;
TImage *Image1;
TGroupBox *GroupBox2;
TLabel *Label1;
TLabel *Label2;
TLabel *Label3;
TGroupBox *GroupBox3;
TLabel *Label4;
void __fastcall FormMouseUp(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
Файл Unit1.cpp
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
// Объявление класса Стрелка
class cl_strel
{
public:
int x_z; //абсцисса
int y_z; //ордината
virtual void create(int x,int y) //создание объекта
{
//Стрелка
TPoint ffpoints1[10];
Form1->Canvas->Brush->Color=clBlack;
ffpoints1[0] = Point(x-12,y-4);
ffpoints1[1] = Point(x-26,y-4);
ffpoints1[2] = Point(x-26,y-32);
ffpoints1[3] = Point(x-40,y-18);
ffpoints1[4] = Point(x-40,y-38);
ffpoints1[5] = Point(x-19,y-59);
ffpoints1[6] = Point(x+2,y-38);
ffpoints1[7] = Point(x+2,y-18);
ffpoints1[8] = Point(x-12,y-32);
ffpoints1[9] = Point(x-12,y-4);
Form1->Canvas->Polygon(ffpoints1, 10);
Form1->Canvas->Brush->Color=clWhite;
x_z=x; // сохранение в памяти абсциссы объекта
y_z=y; // сохранение в памяти отдинаты объекта
};
};
//Наследование потомком Часы
class cl_clock: public cl_strel
{
public:
TPicture *Picture;
virtual void create(int x,int y)
{
Form1->Canvas->CopyMode = cmSrcAnd;
Form1->Canvas->Draw(x,y,Picture->Graphic);
x_z=x; // сохранение в памяти абсциссы объекта
y_z=y; // сохранение в памяти ординаты объекта
};
};
//Наследование потомком Люди
class cl_mans: public cl_strel
{
public:
TPicture *Picture;
virtual void create(int x,int y)
{
Form1->Canvas->CopyMode = cmSrcAnd;
Form1->Canvas->Draw(x,y,Picture->Graphic);
x_z=x; // сохранение в памяти абсциссы объекта
y_z=y; // сохранение в памяти ординаты объекта
};
};
cl_strel Strel1; //Объявление объекта Strel1 класса cl_strel
cl_clock Clock1; //Объявление объекта Clock1 класса cl_clock
cl_mans Mans1; //Объявление объекта Mans1 класса cl_mans
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
//Начальные координаты
Strel1.x_z=1000;
Strel1.y_z=1000;
Clock1.x_z=1000;
Clock1.y_z=1000;
Clock1.Picture = new TPicture;
Clock1.Picture->LoadFromFile("Clock.BMP");
Mans1.x_z=1000;
Mans1.y_z=1000;
Mans1.Picture = new TPicture;
Mans1.Picture->LoadFromFile("Mans.BMP");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormMouseUp(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y)
{
//изменение положения объекта Стрелка
if(RadioButton4->Checked==true)
{
//Стрелка
Form1->Canvas->Rectangle(0,0,1000,1000);
Graphics::TBitmap *BrushBmp = new Graphics::TBitmap;
try
{
BrushBmp->LoadFromFile("Strel.BMP");
Form1->Image1->Canvas->Brush->Bitmap = BrushBmp;
Form1->Image1->Canvas->FillRect(Rect(0,0,Form1->Image1->Width, Form1->Image1->Height));
}
__finally
{
Form1->Image1->Canvas->Brush->Bitmap = NULL;
delete BrushBmp;
}
Strel1.create(X,Y);
Clock1.create(Clock1.x_z,Clock1.y_z);
Mans1.create(Mans1.x_z,Mans1.y_z);
}
//Изменение положения Часы
if(RadioButton5->Checked==true)
{
//Часы
Form1->Canvas->Rectangle(0,0,1000,1000);
Graphics::TBitmap *BrushBmp = new Graphics::TBitmap;
try
{
BrushBmp->LoadFromFile("Clock.BMP");
Form1->Image1->Canvas->Brush->Bitmap = BrushBmp;
Form1->Image1->Canvas->FillRect(Rect(0,0,Form1->Image1->Width, Form1->Image1->Height));
}
__finally
{
Form1->Image1->Canvas->Brush->Bitmap = NULL;
delete BrushBmp;
}
Clock1.create(X,Y);
Strel1.create(Strel1.x_z,Strel1.y_z);
Mans1.create(Mans1.x_z,Mans1.y_z);
}
//Изменение положения Люди
if(RadioButton6->Checked==true)
{
//Люди
Form1->Canvas->Rectangle(0,0,1000,1000);
Graphics::TBitmap *BrushBmp = new Graphics::TBitmap;
try
{
BrushBmp->LoadFromFile("Mans.BMP");
Form1->Image1->Canvas->Brush->Bitmap = BrushBmp;
Form1->Image1->Canvas->FillRect(Rect(0,0,Form1->Image1->Width, Form1->Image1->Height));
}
__finally
{
Form1->Image1->Canvas->Brush->Bitmap = NULL;
delete BrushBmp;
}
Mans1.create(X,Y);
Strel1.create(Strel1.x_z,Strel1.y_z);
Clock1.create(Clock1.x_z,Clock1.y_z);
}
}
//---------------------------------------------------------------------------
