unit Linie_u;
{ Projekt LINIE * Walter Wegscheider / Herwig Reidlinger }
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls, Buttons, ExtCtrls, Menus, clipbrd;
type
TFormLinie =
class(TForm)
Button1: TButton;
Button2: TButton;
Image1: TImage;
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 Button2Click(Sender: TObject);
private
{ Private-Deklarationen }
x_anfang,y_anfang,
x_ende,y_ende:integer;
zeichnen:boolean;
public
{ Public-Deklarationen }
end;
var
FormLinie: TFormLinie;
Bitmap: TBitmap;
implementation
{$R *.dfm}
procedure TFormLinie.FormCreate(Sender: TObject);
begin
FormLinie.DoubleBuffered:=true;
Bitmap:= TBitmap.Create;
Bitmap.PixelFormat:= pf16bit;
Bitmap.canvas.pen.mode:=pmNotXor;
Image1.canvas.pen.style:=pssolid;
Image1.canvas.brush.style:=bsclear;
Bitmap.Height:= Image1.Height;
Bitmap.Width:= Image1.Width;
end;
procedure TFormLinie.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
x_anfang:=x; y_anfang:=y;
x_ende:=x; y_ende:=y;
zeichnen:=true;
end;
procedure TFormLinie.Image1MouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
begin
if zeichnen
then
with Bitmap.Canvas
do
begin
moveto(x_anfang,y_anfang);
lineto(x_ende,y_ende);
x_ende:=x;
y_ende:=y;
moveto(x_anfang,y_anfang);
lineto(x_ende,y_ende);
ClipBoard.Assign(Bitmap);
Image1.Canvas.Draw(0,0,Bitmap);
end;
end;
procedure TFormLinie.Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
zeichnen:=false;
end;
procedure TFormLinie.Button2Click(Sender: TObject);
begin
Bitmap.Assign(Clipboard);
Image1.Canvas.Draw(0,0,Bitmap);
end;
end.