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;