您的位置:首页 > 其它

给控件属性,动态运行时赋值

2015-11-02 11:15 357 查看
procedure RMSetStrProp(aObject: TObject; const aPropName: string; ID: Integer);
var
lStr: string;
lPropInfo: PPropInfo;
begin
lStr := RMLoadStr(ID);
if lStr <> '' then
begin
lPropInfo := GetPropInfo(aObject.ClassInfo, aPropName);
if lPropInfo <> nil then
SetStrProp(aObject, lPropInfo, lStr);
end;
end;

function RMGetPropValue(aReport: TRMReport; const aObjectName, aPropName: string): Variant;
var
pi: PPropInfo;
lObject: TObject;
begin
Result := varEmpty;
if aReport <> nil then
lObject := RMFindComponent(aReport.Owner, aObjectName)
else
lObject := RMFindComponent(nil, aObjectName);

if lObject <> nil then
begin
pi := GetPropInfo(lObject.ClassInfo, aPropName);
if pi <> nil then
begin
case pi.PropType^.Kind of
tkString, tkLString, tkWString:
Result := GetStrProp(lObject, pi);
tkInteger, tkEnumeration:
Result := GetOrdProp(lObject, pi);
tkFloat:
Result := GetFloatProp(lObject, pi);
end;
end;
end;
end;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: