unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;
type
TForm1 = class(TForm)
Image1: TImage;
procedure Image1MouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
procedure Image1MouseMove(Sender: TObject;
Shift: TShiftState;
X,
Y: Integer);
procedure Image1MouseUp(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
procedure FormCreate(Sender: TObject);
private
drawing: boolean;
mousedown: boolean;
posx, posy: integer;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Image1MouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
begin
if drawing then
begin
posX:=X;
posY:=Y;
mousedown:=true;
end;
end;
procedure TForm1.Image1MouseMove(Sender: TObject;
Shift: TShiftState;
X,
Y: Integer);
begin
drawing:=true;
if mousedown then
begin
Image1.Canvas.Pen.Color:=TColor(RGB(225,0,255));
Image1.Canvas.MoveTo(posX,posY);
Image1.Canvas.LineTo(X,Y);
posX:=X;
posY:=Y;
end;
end;
procedure TForm1.Image1MouseUp(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
begin
if drawing then
begin
Image1.Canvas.MoveTo(posX,posY);
Image1.Canvas.LineTo(X,Y);
posX:=X;
posY:=Y;
mousedown:=false;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
drawing:=false;
mousedown:=false;
end;
end.