从 Form1.Caption = “Hello World”说起(7)

2008-04-09 04:28:53来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

}

10: function PtInRect(const r : TRect) : boolean;

11: property X : Integer read GetX write SetX ;

12: property Y : Integer read GetY write SetY ;

13: end;

14:

15: procedure TMyPoint.SetX(const nX: integer);

16: begin

17: if (nX<0) or (nx>1000) then

18: FX := 0

19: else

20: FX := nX;

21: end;

22:

23: function TMyPoint.GetX: Integer;

24: begin

25: result := FX;

26: end;

27:


这样当你执行: pt.X := 200时编译器知道你要执行一个write操作,就会自动跳到procedure TMyPoint.SetX(const nX: integer);处以进行赋值,反之当为read操作时则调用GetX函数。如果GetX只是简单的返回内部的FX值也可以将11行改为:

property X : Integer read FX write SetX ;


由此可知:当我们在Delphi,C Builder中写下Form1.Caption = “…..”时,真正执行的是某个具体的函数,而不是赋值操作

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:用Delphi5.0实现注册表监视

下一篇:浅谈API HOOK技术(二)