例:
Tobject.value   value为single;
可是只能
pointer:=@Tobject;
我想要pointer:[email protected]
该如何做呢?

解决方案 »

  1.   

    ................
    没有必要.不太显示而且..................................
    property只是封装了类似.net的getter和setter方法,实际编译的时候,都会变成property所指向的read的函数或者字段.属性只是在设计时面向用户的
    况且如果
     property myProperty:single;read getMyProp() write setMyProp();那你的myProperty指的是getmyprop还是setmyprop呢?????这样就出现二义性了.所以就算按照楼上说的,也不过是得到的getter函数的返回值的指针,而不是属性的指针.
      

  2.   

    属性只是编译器对read/write的封装,本身不指向实际的地址
      

  3.   

    我觉得是楼主没说清楚吧。如果那个VALUE直接就是一个变量,那就直接按huojiehai(海天子)的方法。否则的话,只会指向一个复制的属性地址的
      

  4.   

    用于下涵數:(注:加入typinfo單元)
    function GetPropPointer(obj: TObject; propName: string): PSingle;
    var
      Getter: Longint;
      PropInfo :PPropInfo ;
    begin
      Result := nil ;
      if obj = nil then Exit ;
      PropInfo:= GetPropInfo(obj,PropName) ;
      if PropInfo=nil then Exit ;
      if PropInfo^.PropType^^.Kind<> tkFloat then Exit ;
      Getter := Longint(PropInfo^.GetProc);
      Result := Pointer(Integer(obj) + (Getter and $00FFFFFF));
    end;
      

  5.   

    忘了說一聲,你的property 必須是published的