unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;
type
TPoint=record
X,Y:Integer;
end;
var
P: array[0..2] of TPoint;
type
TForm1 = class(TForm)
btn1: TButton;
edt1: TEdit;
edt2: TEdit;
edt3: TEdit;
edt4: TEdit;
edt5: TEdit;
edt6: TEdit;
edt7: TEdit;
img1: TImage;
procedure FormCreate(Sender: TObject);
procedure img1MouseUp(Sender: TObject
Button: TMouseButton;
Shift: TShiftState
X, Y: Integer);
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
P[0].X:=0;P[0].Y:=0;
P[1].X:=0;P[1].Y:=0;
P[2].X:=0;P[2].Y:=0;
end;
procedure TForm1.img1MouseUp(Sender: TObject
Button: TMouseButton;
Shift: TShiftState
X, Y: Integer);
begin
P[0].X:=P[1].X;P[0].Y:=P[1].Y;
P[1].X:=P[2].X;P[1].Y:=P[2].Y;
P[2].X:=X;P[2].Y:=Y;
edt1.Text:=IntToStr(P[0].X);
edt2.Text:=IntToStr(P[0].Y);
edt3.Text:=IntToStr(P[1].X);
edt4.Text:=IntToStr(P[1].Y);
edt5.Text:=IntToStr(P[2].X);
edt6.Text:=IntToStr(P[2].Y);
img1.Canvas.Brush.Color:=clWhite;
img1.Canvas.FillRect(img1.ClientRect);
img1.Canvas.MoveTo(P[0].X, P[0].Y);
img1.Canvas.LineTo(P[1].X, P[1].Y);
img1.Canvas.LineTo(P[2].X, P[2].Y);
img1.Canvas.LineTo(P[0].X, P[0].Y);
end;
procedure TForm1.btn1Click(Sender: TObject);
var
SSS:Integer;
begin
SSS := P[0].X*P[1].Y + P[1].X*P[2].Y + P[2].X*P[0].Y
- P[0].X*P[2].Y - P[1].X*P[0].Y - P[2].X*P[1].Y;
SSS := SSS div 2
edt7.Text:=IntToStr(SSS);;
end;
end.