码迷,mamicode.com
首页 > 编程语言 > 详细

C++builder 递归获取继承基类根类

时间:2015-07-12 23:18:09      阅读:154      评论:0      收藏:0      [点我收藏+]

标签:

    TClass ClassRef;
    ListBox1->Clear();
    ClassRef = Sender->ClassType();
    while (ClassRef != NULL)
    {
        ListBox1->Items->Add(ClassRef->ClassName());
        ClassRef = ClassRef->ClassParent();
    };

 

#include <memory>       //For STL auto_ptr class
 
TMetaClass *MetaClass;
 
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  std::auto_ptr<TClassFinder> myClassFinder(new TClassFinder(MetaClass, False));
  TGraphicClass mygraphclass = (TGraphicClass) (myClassFinder->GetClass(Edit2->Text));
//  TGraphicClass mygraphclass = (TGraphicClass) GetClass(Edit2->Text);
  Edit1->Text = GraphicExtension(mygraphclass);
}
 
__fastcall TForm1::TForm1(TComponent* Owner)
    : TForm(Owner)
{
  MetaClass = __classid(TIcon); // ico
  RegisterClasses(&MetaClass, 0);
  MetaClass = __classid(Graphics::TBitmap); // bmp
  RegisterClasses(&MetaClass, 0);
  MetaClass = __classid(TMetafile); // emf
  RegisterClasses(&MetaClass, 0);
  MetaClass = __classid(TShape);  // no graphic extension
  RegisterClasses(&MetaClass, 0);
  MetaClass = __classid(TImage); // no graphic extension
  RegisterClasses(&MetaClass, 0);
}

http://docwiki.embarcadero.com/CodeExamples/XE8/en/ClassesGetClass_%28C%2B%2B%29

 

C++builder 递归获取继承基类根类

标签:

原文地址:http://www.cnblogs.com/cb168/p/4641709.html

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