访问受保护的财产 [英] Access protected property

查看:60
本文介绍了访问受保护的财产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个从Tobject派生的类.在我的课堂上,我想使用控件的受保护属性.这是我的代码

I have a class that is derived from Tobject. In my class i want to use protected properties of control. Here is my code

    type
    THack = class(Tcontrol);

    TMyClass = class(TObject)
    private
      A: string;
      B: string;
      C: string;
      D: string;
    public
      procedure DoSomthing(MyForm: TForm);
    end;

  procedure TMyClass.DoSomthing(MyForm: TForm);
  var
    I: Integer;
  begin
    for I := 0 to MyForm.ControlCount - 1 do
    begin
      // I want to read Font property
      showmessage(inttostr(THack(MyForm.Controls[I]).Font.Size));
   end; 
  end;

我还有其他方法可以访问受保护的属性

Is there any other way i can access protected properties

推荐答案

我知道可以执行此任务的选项是:

The options that I am aware of that can perform this task are:

  1. 该问题中展示的经典受保护的骇客.
  2. 新型RTTI.
  3. 一个班级助手.

这篇关于访问受保护的财产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆