TManagedForm class

(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:

  1. 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)
  2. The constructor Create uses GenerateName to set its Name property, so the check is possible.
  3. 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:

    1. 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)
    2. 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.
    3. 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.
    4. DoLoadFormState reads the form’s state from the registry. It can set the form position and size and set a splitter position.
    5. 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.
    6. DoResizePictureDialogs searches for TOpenPictureDialog components on the form and adds ofEnableSizing to its options.
    7. DoComboDropDownCount changes the dropdown count of TCustomCombobox descendants (with some exceptions where this has undesired side effects).

There are several descendants from this class: