var  PropInfo:PPropInfo;
  
  PropInfo:=GetPropInfo(controls[i].ClassInfo,'Text');
  if (PropInfo<>nil) then
    SetStrProp(controls[I], PropInfo, Sstr)
  else
  begin
    PropInfo:=GetPropInfo(controls[i].ClassInfo,'Lines'); //这里是Memo控件,就不知道怎么写
    if (PropInfo<>nil) then
    begin
      PropInfo:=GetPropInfo(GetObjectProp(controls[i],'Lines',Tstrings).classinfo,'Text');
      if (PropInfo<>nil) then
      SetStrProp(controls[I], PropInfo, Sstr);
      end;
  end;GetPropInfo 函数判断传回值是否为 nil 来决定是否有这个属性.但是MEMO控件LINE属性下有TEXT,上面这样写有问题,应该怎么写呢?谢谢!~

解决方案 »

  1.   

    var  PropInfo:PPropInfo;
      
      PropInfo:=GetPropInfo(controls[i].ClassInfo,'Text');
      if (PropInfo<>nil) then
        SetStrProp(controls[I], PropInfo, Sstr)
      else
      begin
        PropInfo:=GetPropInfo(controls[i].ClassInfo,'Lines'); //这里是Memo控件,就不知道怎么写
        if (PropInfo<>nil) then
        begin
          PropInfo:=GetPropInfo(GetObjectProp(controls[i],'Lines',Tstrings).classinfo,'Text');
          if (PropInfo<>nil) then
            //SetStrProp(controls[I], PropInfo, Sstr);
            TStrings(GetObjectProp(controls[I], 'lines')).text := Sstr; //改成这个
          end;
      end;