procedure TForm1.PaintBox1Paint(Sender:TObject);
begin
  with Sender as TPaintBox do
  if Shape=1 then
  begin
  Canvas.pen.color:=clblack;
  Canvas.ellipse(0,0,30,30);
 end;
end;我以为TPaintBox是Sender的别名。我在后面改成TPaintBoxx编译时出错。请大侠指点。谢谢!

解决方案 »

  1.   


    as是把Sender转换成TPaintBox类型with ... do是开域语句
      

  2.   

    TPaintBox是delphi中的类名,Sender as TPaintBox 是把Sender强制转换成例TPaintBox的实例。
      

  3.   

    TPaintBox是delphi中的类名,Sender as TPaintBox 是把Sender强制转换成例TPaintBox的实例。
      

  4.   

    TPaintBox是类,他的名字也是TPaintBox,
    as是执行类型检查,把sender对象转换为TPaintBox的接口,
    转化的时候Sender必须是TObject或者TObject的子孙类的实例
    或者为nil,否则就会触发异常。
      

  5.   

      sender 是什么意思