(Note: This is the legacy class for form enhancements, even though it has been updated from the original way of a single class and an array of Records with the settings. I’m working on moving that functionality to the TManagedFormHandler class.)
The base class TManagedForm is derived from TComponent, so it can be added as a component to the form it enhances.
It has only a few public methods:
- The class function AlreadyExists checks whether a given form already contains a component with the unique name based on the form it manages (See the private class function GenerateName)
- The constructor Create uses GenerateName to set its Name property, so the check is possible.
- The procedure Init does any changes to the form. It has a record parameter which configures which parts of the form should be changed, e.g. whether it needs to be made sizeable, whether to store its size and position etc.
Init calls several virtual methods that can be overridden by descendants:- DoHookOnFormDestroy hooks the form’s OnDestroy event, storing its original value, so it gets notified when the form is being destroyed to save its state. (todo: This might be replaced with using the built in notification mechanism of TComponent)
- DoMakeResizable checks whether the form is supposed to be made sizable and if yes, calls the virtual procedure MakeComponentsResizable in case the form needs tweaking to become sizeable. it then forces the form to actually become sizeable, possibly using a hack.
- DoFixFormErrors is a virtual method that does nothing in the base class. Descendants implement it to fix various issues with Forms in the IDE, depending on the IDE version. E.g. some forms need to be moved to the correct monitor, others have an unnecessary scroll bar that gets disabled.
- DoLoadFormState reads the form’s state from the registry. It can set the form position and size and set a splitter position.
- DoCollapseTreeNodes is a special method for configuration dialogs used in the Delphi IDE since Delphi 2005. It collapses some rarely used tree nodes, e.g. the Together node. It does nothing in the base class.
- DoResizePictureDialogs searches for TOpenPictureDialog components on the form and adds ofEnableSizing to its options.
- DoComboDropDownCount changes the dropdown count of TCustomCombobox descendants (with some exceptions where this has undesired side effects).
There are several descendants from this class:
- TManagedFormImageListEditor (Delphi 6 only)
- TManagedFormPictureEditDlg
- TManagedFormSrchDialog (Delphi 6 only)
- TManagedFormRplcDialog (Delphi 6 to 2007)
- TManagedFormDefaultEnvironmentDialog (Delphi >= 2005)
- TManagedFormConnEditForm
- TManagedFormPakComponentsDlg
- TManagedFormPasEnvironmentDialog (Delphi 6 and 7)
- TManagedFormProjectOptionsDialog
- TManagedFormFixFormPositioningOnly (used for various forms)
- TManagedFormAboutBox (Delphi 2005 and 2006)