本帖最后由 cowbo2 于 2009-08-12 20:26:04 编辑

解决方案 »

  1.   


    var
      Form1: TForm1;
      DrawType:SHORT;
      Cir:TShape;
      StartPont:TPoint;
      EndPoint:TPoint;
      iTag: Integer = 0;
    implementation{$R *.dfm}procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    begin
      iTag := 1;
      StartPont:=Point(x,y);
      Cir:=TShape.Create(nil);
      Cir.Left:=x;
      Cir.Top:=y;
      Cir.Brush.Style:=bsClear;
      Cir.Parent:=Form1;
    end;procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    begin
      if iTag = 1 then
      begin
        Cir.Width:=X - StartPont.X;
        Cir.Height:=Y - StartPont.Y;
        Cir.Shape:=stCircle;
      end;
    end;procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    begin
      iTag := 2;
      Cir.Width:=X - StartPont.X;
      Cir.Height:=Y - StartPont.Y;
      Cir.Shape:=stCircle;
      Cir.Free;
    end;
      

  2.   

    帮你加了个控制的变量,还改了这句Cir:=TShape.Create(nil);因为你下面已经调用了Free,所以这里参数用nil.如果用form1表示在form1 free的时候同时会free Cir;
      

  3.   


    2楼你好!Image1是放在ScrollBox1里但为什么
     Cir.Parent:=ScrollBox1;的话,绘的图,有的不显示不全?而用
    Cir.Parent:=Image1;则报错。
      

  4.   

    TWinControl的后代,才能容纳子控件。
    ScrollBox是TWinControl的后代,Image不是