unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TPunkt =
Record
xpos,ypos:integer
end;
TForm1 =
class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Image1: TImage;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
Edit8: TEdit;
Button2: TButton;
Button1: TButton;
procedure Image1Click(Sender: TObject);
procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
geklickt:boolean=false;
punkta,punktb:TPunkt;
implementation
{$R *.dfm}
procedure TForm1.Image1Click(Sender: TObject);
var ypos,xpos:integer;
begin
xpos:=mouse.CursorPos.X-image1.Left;
ypos:=mouse.CursorPos.y-image1.Top-27;
image1.Canvas.MoveTo(xpos,ypos);
image1.Canvas.lineto(xpos+1,ypos);
edit3.Text:=IntToStr(ypos);
edit4.Text:=IntToStr(xpos);
if not geklickt
then
begin
punkta.xpos:=mouse.CursorPos.X-image1.Left;
punkta.ypos:=mouse.CursorPos.y-image1.Top-27;
geklickt:=true;
edit5.Text:=IntToStr(punkta.xpos);
edit6.Text:=IntToStr(punkta.ypos);
end
else
begin
punktb.xpos:=mouse.CursorPos.X-image1.Left;
punktb.ypos:=mouse.CursorPos.y-image1.Top-27;
geklickt:=false;
edit7.text:=IntToStr(punktb.xpos);
edit8.text:=IntTOStr(punktb.ypos);
end;
end;
procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
edit1.Text:=IntToStr(mouse.CursorPos.X);
edit2.Text:=IntToStr(mouse.CursorPos.y);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if geklickt=false
then
image1.canvas.rectangle(punkta.xpos,punkta.ypos,punktb.xpos,punktb.ypos)
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if geklickt=false
then
image1.Picture.Bitmap.Canvas.r(punkta.xpos,punkta.ypos,punktb.xpos,punktb.ypos);
end;
end.