Is possible create (register) a new class in runtime using delphi.
I have a Class called TMyForm, is possible create a new form derived from TMyForm but with new class type.
i want something like this
var
Myform : TMyForm;
MyFormClassBase : TFormClass;
begin
MyFormClassBase := TFormClass(RegisterMyNewClass('TMyNewClass'));//obviously RegisterMyNewClass does not exist
Myform := MyFormClassBase.Create(Application);
Myform.Show;
end;
i am using delphi 7
UPDATE 1
I dont look create a new instance of the same base class, i need create an new class type in runtime derived from another class.
UPDATE 2
Thank you very much for your interest. but the purpose is a bit complex to explain (because my bad english). I have a form that allows you to edit multiple master data tables, all these tables have the same fields code (an integer primary key) and description (a varchar field), they serve to define currencies, countries, projects, groups, etc.
as logic is the same for all these tables, so only need this form by passing as parameters the title of the table name , to manage these tables. something like this
FormCurrency:= TMyForm.Create( 'Define currencys', 'CURRENCYTABLE')
if ValidateAccess(FormCurrency) then
FormCurrency.Show
else
FormCurrency.Close;
FormGroups:= TMyForm.Create( 'Define Groups', 'GROUPSTABLE')
if ValidateAccess(FormGroups) then
FormGroups.Show
else
FormGroups.Close;
on the other hand I have a validation method (called ValidateAccess) that validates the users access to the forms using the form's class . because of this if you use the same kind of form is restricted access to all the options like "define groups","define currencys", "define countrys" (which I do not want that to happen), because that i need to pass to the ValidateAccess method a diferent class.
I cannot rewrite the ValidateAccess method because exist many diferents forms already registered in the system.
I dont want create a new form type and a new unit over and over just changing the title and the table to use.
Thanks in Advance.