为什么动态生成Shape不成功?---------高人请帮看看 本帖最后由 cowbo2 于 2009-08-12 20:26:04 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 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; 帮你加了个控制的变量,还改了这句Cir:=TShape.Create(nil);因为你下面已经调用了Free,所以这里参数用nil.如果用form1表示在form1 free的时候同时会free Cir; 2楼你好!Image1是放在ScrollBox1里但为什么 Cir.Parent:=ScrollBox1;的话,绘的图,有的不显示不全?而用Cir.Parent:=Image1;则报错。 TWinControl的后代,才能容纳子控件。ScrollBox是TWinControl的后代,Image不是 600分求教!!使用WEBSNAP写ISAPI程序,如何使用Web App Debugger进行跟踪调试????? 36选7的算法一共有多少种选法 FastMM怎么老抓不准泄露的代码位置呢,急等 Listbox控件中,能不能取出选择的那一行的文本? 如何模拟按下TAB键?? Wise 制作安装如何指定默认路径到其他盘符? 关于Edit! 很菜的问题!! 关于模糊查询的问题? 关于dll的小问题 WebService调用失败 delphi的类的属性前面加property与不加property有何区别?
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楼你好!Image1是放在ScrollBox1里但为什么
Cir.Parent:=ScrollBox1;的话,绘的图,有的不显示不全?而用
Cir.Parent:=Image1;则报错。
ScrollBox是TWinControl的后代,Image不是