We use C++ Builder for an application whose forms are kept external to the EXE in a database. Application code is C++
This allows us to modify the forms and form/actions without a re-compile. Here is a snippet of code that gets the job done of loading a form.
RegisterClass(__classid(TButton));
RegisterClass(__classid(TEdit));
RegisterClass(__classid(TRadioGroup));
RegisterClass(__classid(TGroupBox));
RegisterClass(__classid(TCheckBox));
RegisterClass(__classid(TRadioButton));
RegisterClass(__classid(TTimer));
RegisterClass(__classid(TListBox));
RegisterClass(__classid(TComboBox));
RegisterClass(__classid(TBitBtn));
RegisterClass(__classid(TSpeedButton));
RegisterClass(__classid(TMaskEdit));
RegisterClass(__classid(TProgressBar));
ms = new TMemoryStream;
ms2 = new TMemoryStream;
// Loading Module into Memory Stream
ms->Position = 0;
ms->LoadFromFile(Filename->Text);
ms->Position = 0;
pModule = new TForm(this);
// Reading Module Definition
if( !Inputisbin->Checked )
{
ms2->Position = 0;
ObjectTextToBinary(ms, ms2);
ms2->Position = 0;
ms2->ReadComponent(pModule);
}
else
ms->ReadComponent(pModule);
Log->Lines->Add("Displaying Module");
pModule->Show();
I'm curious to know if there are any built-in functions I can call to register all classes referenced. I suppose it's possible to scan the memory stream or file for all objects myself and call RegisterClass for each but was hoping someone knew of function that already did this.
As such, not all forms use all these classes either so it would be nice to only register those that are actually inherited.