procedure TForm2.Image1MouseMove (Sender: TObject; Shift: TShiftState; X, Y: Integer); begin if trace=true then //是否在追踪鼠标? begin //是,擦除旧的矩形并画上新的矩形 with image1.canvas do begin rectangle(x1,y1,oldx,oldy); Rectangle(x1,y1,x,y); oldx:=x; oldy:=y; end; end else if flag=true then //在鼠标所在的位置上画十字 begin with image1.canvas do begin moveTo(foldx,0); //擦除旧的十字 LineTo(foldx,screen.height); moveto(0,foldy); lineto(screen.width,foldy); moveTo(x,0); //画上新的十字 LineTo(x,screen.height); moveto(0,y); lineto(screen.width,y); foldx:=x; foldy:=y; end; end; end;