type
TForm1 = class(TForm)
Image1: TImage;
procedure FormCreate(Sender: TObject);
procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
TMyCursor = Class
oldRect : TRect;
Constructor Create;
Destructor Destory;
private
procedure DoMove( x , y: Integer);
end;
var
Form1 : TForm1;
MyCursor: TMyCursor;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
var
I,J, wC, hC : Integer;
begin
wC:= Image1.Width div 32;
hC:= Image1.Height div 32;
For I:=1 to wc-1 do
Begin
Image1.Canvas.MoveTo(I*32 , 0);
Image1.Canvas.LineTo(I*32 , Image1.Height);
end;
For J:=1 to hC-1 do
Begin
Image1.Canvas.MoveTo(0 , J*32);
Image1.Canvas.LineTo(Image1.Width , J*32);
end;
MyCursor:= TMyCursor.Create;
DoubleBuffered:= True;
end;
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls;
type
TForm1 = class(TForm)
Image1: TImage;
procedure FormCreate(Sender: TObject);
procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
TMyCursor = Class
oldRect : TRect;
Constructor Create;
Destructor Destory;
private
procedure DoMove( x , y: Integer);
end;
var
Form1 : TForm1;
MyCursor: TMyCursor;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
var
I,J, wC, hC : Integer;
begin
wC:= Image1.Width div 32;
hC:= Image1.Height div 32;
For I:=1 to wc-1 do
Begin
Image1.Canvas.MoveTo(I*32 , 0);
Image1.Canvas.LineTo(I*32 , Image1.Height);
end;
For J:=1 to hC-1 do
Begin
Image1.Canvas.MoveTo(0 , J*32);
Image1.Canvas.LineTo(Image1.Width , J*32);
end;
MyCursor:= TMyCursor.Create;
DoubleBuffered:= True;
end;
{ TMyCursor }
constructor TMyCursor.Create;
var
sPoint, NowPoint : TPoint;
begin
GetCursorPos(sPoint);
NowPoint:= Form1.Image1.ScreenToClient(sPoint);
Form1.Image1.Canvas.Ellipse(NowPoint.x-10, NowPoint.y-10, NowPoint.x+10, NowPoint.y+10);
OldRect:= Rect(NowPoint.x-10, NowPoint.y-10, NowPoint.x+10, NowPoint.y+10);
end;
destructor TMyCursor.Destory;
begin
Inherited;
end;
procedure TMyCursor.DoMove(x, y: Integer);
var
OldPenMode: TPenMode;
begin
OldPenMode:= Form1.Image1.Canvas.Pen.Mode;
With Form1 do
Begin
Image1.Canvas.Pen.Mode:= pmNotXor;
Image1.Canvas.Ellipse(OldRect);
Image1.Canvas.Ellipse(x-10, y-10, x+10, y+10);
OldRect:= Rect(x-10, y-10, x+10, y+10);
Image1.Canvas.Pen.Mode:= OldPenMode;
end;
end;
procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
MyCursor.DoMove(x,y);
end;
end.