Board index » cppbuilder » creating instance by class name does not work
Frank Birbache
![]() CBuilder Developer |
Wed, 10 Nov 2004 22:15:15 GMT
creating instance by class name does not work
Hi!
I want to create an instance of an VCL object whose name is given as a TControl *CreateInstanceOf(std::string ClassName); I searched this newsgroup and found a "working" and a "good" example at http://home.att.net/~robertdunn/CodeSamples/CodeSnips.html#Bmk011 However, I tried the Delphi version (which is titled "perfect So I tried the C++ example (the "working" one): It compiles but TObject* CreateMetaClassObject(TMetaClass* metaClass) Quote} { TObject *obj(CreateMetaClassObject(FindClass("TEdit"))); TControl *con(dynamic_cast<TControl*>(obj)); So I added the following in the form constructor: RegisterClass(__classid(TEdit)); Ok, compiles, but the created object seems invalid. When I try to assign if(con) it crashes. However Left,Top,Width and Height don't throw (when I What's wrong here? Frank |