比如说,我在CANVAS上绘有一条直线,现在想把他擦除,但不能用更新的方法,如Invalidate,因为晃得太厉害啦,我记得以前可以通过设置Canvas.CopyMode的属性来重绘即可擦除,象DrawFocusFrame一样,第二次绘制时就可擦除一个热点框.有谁知道怎么擦除一条线吗?谢谢大家

解决方案 »

  1.   

    唉,悲啊,我来替你回答吧:其实很简单,就这一句:Image1.Canvas.Pen.Mode:=pmNot;
    设置这个模式,你在同一个地方画一次出现直线,再画一次就把直线擦除了,明白了吗。不过这样的问题是可以通过帮助来解决的,要学会看帮助,这个才是最重要的
      

  2.   

    xiaoxiao197821(你的笑对我很重要)的方法是绝对有用的,可惜你不尝试,
    游戏编程中最常用到的方法!
      

  3.   

    我這裡有實現這個的代碼,給你提示:
    type pLine=^recordLine;
         recordLine=record
         originP,finalP:TPoint;
         lineColor:TColor;
         next:pLine;
         end;
    procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    begin
      if button=mbLeft then
      begin
        drawing:=true;             
        image1.Canvas.Pen.Color :=colorbox1.Selected;
        origin:=Point(x,y);         
        movePt:=origin;
    ……
    procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    begin
    if button=mbLeft then
    begin
      if drawing then            
      begin
        drawing:=false;          
        case myDrawStart of             
        myLine:
        begin
         new(itsLine^.next);             
         itsLine:=itsLine^.next;
         itsLine^.originP:=origin;
         itsLine^.finalP:=movePt;
         itsLine^.lineColor:=image1.Canvas.Pen.Color;
         itsLine^.next :=nil;
         lastLine:=itsLine;
        end;     dLine^.next :=itsLine^.next ;
          if itsLine=lastLine then
             lastLine:=dLine;
          dispose(itsLine);  //這裡就可以刪除所選擇的任何綫
          itsLine:=lastLine;