当前位置:首页 » 业界相关

对vcl库底层机制一些不明白的地方4

 Advertisement:

热门软件下载:


刚刚写了一个可视控件,但在发布它的一些属性时遇到了点问题。  
  这个属性的值我希望以下拉列表提供。  
  下面是我的代码。请各位高手指点。  
  .h  
  class   tfieldnamepropertyeditor:   public   tpropertyeditor  
  {  
  public:  
            __fastcall   tfieldnamepropertyeditor(const_di_idesigner   adesigner,   int   apropcount);  
            virtual   __fastcall   ~tfieldnamepropertyeditor(void);  
            tpropertyattributes   __fastcall   getattributes(void);  
            void   __fastcall   getvalues(classes::tgetstrproc   proc);  
  };  
  //---------------------------------------------------------------------------  
  ttypeinfo*   ansistringtypeinfo(void);     //定义类型信息  
    .cpp  
  namespace   newcomponent  
  {  
        void   __fastcall   package   register()  
        {  
              registerpropertyeditor(ansistringtypeinfo(),   __classid(tnewcomponent),   "parentidfield",   __classid(tfieldnamepropertyeditor));//注册属性  
              registerpropertyeditor(ansistringtypeinfo(),   __classid(tnewcomponent),   "idfield",   __classid(tfieldnamepropertyeditor));//注册属性  
              registerpropertyeditor(ansistringtypeinfo(),   __classid(tnewcomponent),   "displayfield",   __classid(tfieldnamepropertyeditor));//注册属性  
   
              tcomponentclass   classes[1]   =   {__classid(tnewcomponent)};  
              registercomponents("samples",   classes,   0);  
        }  
  }  
  //------------------------------------------------------------------  
   
  __fastcall   tfieldnamepropertyeditor::tfieldnamepropertyeditor(const_di_idesigner   adesigner,   int   apropcount)  
                                                                                        :tpropertyeditor(adesigner,apropcount)  
  {  
   
  }  
  //---------------------------------------------------------------------------  
   
  virtual   __fastcall   tfieldnamepropertyeditor::~tfieldnamepropertyeditor()  
  {  
   
  }  
  //---------------------------------------------------------------------------  
   
  tpropertyattributes   __fastcall   tfieldnamepropertyeditor::getattributes(void)  
  {  
                  return   tpropertyattributes()   <<   pavaluelist;  
  }  
  //--------------------------------------------------------------------------  
   
  void   __fastcall   tfieldnamepropertyeditor::getvalues(classes::tgetstrproc   proc)    
  {  
          tnewcomponent*   n;  
          n   =   (tnewcomponent*)getcomponent(0);  
   
          for   (int   i   =   0;   i   <   n->items->count;i++)  
        {  
                        proc(n->items->strings[i]);  
          }  
  }  
  //---------------------------------------------------------------------------  
   
  ttypeinfo*   ansistringtypeinfo(void)     //定义类型信息  
  {  
        ttypeinfo*   typeinfo   =   new   ttypeinfo;  
        typeinfo->name   =   "ansistring";  
        typeinfo->kind   =   tklstring;  
        return   typeinfo;  
  }  
  //---------------------------------------------------------------------------  
 

推荐阅读

  • 索尼蓝光阵营首次出击中国 推出四款全新产品 [详细内容]
  • 中海园电子城展台 [详细内容]
  • BEL [详细内容]
  • 索尼高级户外耳机全面提高户外音乐享受 [详细内容]
  • 心机变普机 [详细内容]
  • LITTELFUSE:精心研究您的需求 [详细内容]
  • 索尼Walkman NW-S700F/S600系列发布 [详细内容]
  • 网友回答:
    网友:maxchou

    学习

    .  

    相关评论

    Login