When you create a Vcl application in C++Builder, it auto-creates forms for you and adds lines like:
Application->CreateForm(__classid(Tmain), &main);
I tend to prefer to use new
to create forms, so remove all of these lines except the one for my main form (see this article by Rob Kennedy for some discussion).
What I have discovered recently is that CreateForm() will quite happily create forms that contain pure virtual methods. Which can lead to "pure virtual function called" errors at run-time. In contrast, creating the form using new
gives a compile-time "cannot create instance of abstract class" error.
Compile-time errors being preferable to run-time errors, I have to wonder whether I can use new
on all forms, including the main form? What other stuff is Application.CreateForm()
doing behind the scenes and can I duplicate this?