Reputation: 353
i using delphi 7 and my project have many available form.
i tried to execute application.component[i].classname
to get all available form classname, but i only get list of created form classname.
is there way to get all available form classname in project to listbox?
Upvotes: 0
Views: 1920
Reputation: 612934
You could use the built in class registry.
RegisterClass(TMyForm)
. Do this from an initialization section, typically that of the unit which defines the class.FindClass
passing the class name.FindClass
returns a class that inherits from TForm
.Application.CreateForm
or just calling the Create
virtual constructor of the class.The instantiation looks like this:
var
MyClass: TPersistentClass;
Form: TForm;
....
MyClass := FindClass(ClassName);
if MyClass.InheritsFrom(TForm) then
Form := TFormClass(MyClass).Create(AnOwner);
Upvotes: 2