码迷,mamicode.com
首页 > Windows程序 > 详细

将一个字符串映射为一个Delphi页面控件属性名(通过FindComponent和GetPropInfo找到这个控件指针)

时间:2016-10-12 06:44:56      阅读:297      评论:0      收藏:0      [点我收藏+]

标签:

uses   TypInfo;   
    
  function   TForm1.SetControlProp(ComStr,   value:   string):   boolean;   
  var   ComName,   ComProp:   string;   
          i:   integer;   
      Loop:   Integer;   
      PropInfo:   PPropInfo;   
      cp:   TComponent;   
  begin   
      i   :=   Pos(.,   ComStr);   
      if   i   >   0   then   
      begin   
          ComName   :=   copy(ComStr,   1,   i-1);   
          ComProp   :=   Copy(Comstr,   i+1,   1000);   
          cp   :=   FindComponent(ComName);   
          PropInfo   :=   GetPropInfo(cp.ClassInfo,   ComProp);   
          if   Assigned(PropInfo)   then   
              SetStrProp(cp,   PropInfo,   value);   
      end;   
  end;   
    
  procedure   TForm1.Button3Click(Sender:   TObject);   
  begin   
    SetControlProp(button1.caption,   test);   // 設置button1的caption   為   test   
  end;   

 

http://www.cnblogs.com/kfarvid/archive/2009/10/19/1586229.html

将一个字符串映射为一个Delphi页面控件属性名(通过FindComponent和GetPropInfo找到这个控件指针)

标签:

原文地址:http://www.cnblogs.com/findumars/p/5951309.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!