In previous versions of Delphi, my custom Form showed its published properties.
However, I'm running into an issue with Delphi 10.2 Tokyo. Specifically, I'm not seeing a good way to call the appropriate method found in this post.
To sum it up, a call to RegisterCustomModule()
is needed, however, in the DesignIntf
unit described here, there is no TCustomModule
(there is TBaseCustomModule
and TCustomModuleClass
, though), also the base custom module inherits from TInterfacedObject
, which TForm
does not (using FMX as my framework).
What is the correct method for registering a FMX Form to show published properties in the latest version of Delphi?
uses DesignEditors;
type
TMySpecialForm = class(TCustomForm)
end;
RegisterCustomModule(TMySpecialForm, TCustomModule);
RegisterCustomModule
takes 2 parameters: ComponentBaseClass
and CustomModuleClass
. The first is your custom form class, which will, of course, be derived from TCustomForm
. The second is a class that will be used by the designer. This class must do 2 things: derive from TBaseCustomModule
(in DesignIntf
unit) and implement the ICustomModule
interface. Take a look at the comment in the DesignEditors
unit, around line 502.
The TCustomModule
class is provided for you to use if you have no behavior other than the default to add to your custom form at design time.
If you do want some kind of custom behavior for your form while in the designer, say, a pop-up menu with various property-setting commands, you would create your own TCustomModule
class:
uses DesignEditors;
type
TMySpecialFormDesigner = class(TCustomModule, ICustomModule)
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
end;
RegisterCustomModule(TMySpecialForm, TMySpecialFormDesigner);