[Lazarus] Is it meaningful or possible to change the visibility or the properties and events in a form or datamodule, ie make the private or protected?
Sven Barth
pascaldragon at googlemail.com
Fri Mar 23 15:30:08 CET 2012
Am 23.03.2012 15:13, schrieb Frank Church:
> On 23 March 2012 13:49, Sven Barth<pascaldragon at googlemail.com> wrote:
>> Am 23.03.2012 14:11, schrieb Frank Church:
>>
>>> Is it meaningful or possible to change the visibility or the
>>> properties and events in a form or datamodule, ie make the private or
>>> protected?
>>>
>>> Of late when I look the definition of a form, it all seems so odd to
>>> me that properties, objects etc which are not meant to be accessible
>>> to external modules are automatically visible.
>>>
>>> I just want to check on how the form or module fits into the overall
>>> program just by looking at the public and published properties. Am I
>>> missing something about the ideas about Delphi and Lazarus which are
>>> supposed to be obvious?
>>>
>>
>> All objects that should be placed in the lfm/dfm file MUST be placed in the
>> published section in Delphi and Lazarus, because they are only streamed if
>> there is RTTI for them for which "published" was created. Yes, there are
>> other approaches, e.g. fpGUI has an IDE that has the GUI creation in code
>> and of which the IDE parses and modifies the "initialization routine" to
>> display a designer form, and another possiblity would be - if they'd be
>> implemented in FPC - the extended RTTI which allows you to specify that also
>> e.g. private fields have RTTI generated and (with an adjusted streaming
>> system) this could also be used. But neither Delphi nor Lazarus uses this
>> approach, so you must live with that (for now).
>>
>
> I remember this aspect form asking a similar question some time back.
> What of the event handlers, is it the nature of the form designer
> which requires them to be visible as well? It is possible also to set
> an eventhandler to a routine in other file, but ideally shouldn't that
> be something the develop can choose to expose only when he requires
> it?
If you want to set event handlers through the object inspector, then you
need to have them published as well, because only then "MethodAddress"
which is used in the streaming will return something besides Nil.
> I am now considering placeing an intermediate classes between the
> consumers and producers in order to hide those details, so that
> instead of some form calling a data module directly, it calls an
> intermediate class that accesses the data module through the methods
> and properties of that class..
This is maybe one of the better approaches you can do.
Regards,
Sven
More information about the Lazarus
mailing list