In my Delphi 2009 VCL application, I have several base forms, like:
TListBaseForm = class(TForm)
TEditableListBaseFrom = class(TForm)
TEditBaseForm = class(TForm)
Each of these base forms is using the usual inheritance mechanism - they have a .pas file and a .dfm file, and the .dfm file contains a lot of pre-set properties, like FormStyle. I understand that such dfm-saved properties are better not changed during the inheritance.
And the application contains, of course, a lot of forms that inherit directly from TForm and not from any of those application base forms.
I would like to create an additional class TAppBaseForm = class(TForm), but without a .dfm file, and use in a way that I could just replace:
TListBaseForm = class(TForm)
TEditableListBaseFrom = class(TForm)
...
TSomeCustomForm = class(TForm)
With:
TListBaseForm = class(TAppBaseForm)...
TEditableListBaseForm = class(TAppBaseForm)...
...
TSomeCustomForm = class(TAppBaseForm)
Just by changing the .pas files and without bothering to create or maintain a TAppBaseForm.dfm file for the TAppBaseForm class.
Is this possible?
I just want to have some non-dfm related logic inside TAppBaseForm which doesn't need a .dfm file, eg one can re-assignment some properties for all of the relevant components in the form that shall happen in the constructor or OnCreate event handler of this base form.
A very specific example is about the application of DevExpress skins. If there is a skin specified, then TcxButton.LookAndFeel.NativeStyle:=False; shall be used. If the user opts not to use DevExpress skins, then it is better to have TcxButton.LookAndFeel.NativeStyle:=True; instead.
I guess, there are many other programmatic UI tweaks that can sit in the base class of the application, and which just uses a collection of Components or Controls that are not referencing specific components from any DFM.
I actually use a similar approach in my CmonLib in unit Cmon.Vcl.Forms.pas.
It basically declares a DFM-less TCommonForm = class(TForm) and later adds a type alias TForm = TCommonForm. The latter allows to keep the declaration as is TListBaseForm = class(TForm) and just add the new Cmon.Vcl.Forms to the interface uses clause after Vcl.Forms.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With