[Lazarus] LCL improvement idea

michael.vancanneyt at wisa.be michael.vancanneyt at wisa.be
Tue Jan 18 14:02:12 CET 2011



On Tue, 18 Jan 2011, Max Vlasov wrote:

> On Tue, Jan 18, 2011 at 2:11 PM, <michael.vancanneyt at wisa.be> wrote:
>
>>
>>
>>  Hmm, Michael, I understand you here, but I think that the main drawback
>>> about application-wide (so possibly run-time only) is about losing
>>> design-time magic. For example when you have 10 panels, go change some
>>> design-time property and they changed their view all at once without even
>>> running anything. If they're form-only and design-time, you still can
>>> imitate application-wide defaults inheriting from common ancestor and
>>> placing all you defaults there, but you will keep this magic at your
>>> fingers
>>>
>>
>> The whole point is to avoid having to do the same task all over again.
>> Remember, a typical app of mine has more than 1000 forms.
>>
>> If you set a property at design time, the 'default' is overridden anyway: -
>> Default is applied at control creation. - When the control is loaded from
>> stream, control-specific values are set,
>>  and override the defaults.
>>
>>
>
> Ok, now I see, your initial idea is really simple and working, the one I
> suggested maybe needs a little more thinking about worth it or not
> implementing. I know it can work, but for the time being looks a little bit
> too complex
>
> For yours I have something in mind. Is it possible to create something
> similar to TApplicationEvents (in terms of accessing special places in the
> LCL) and this component that will introduce an event
>
> TOnCreateComponent: procedure (Sender: TObject; Component: TComponent) of
> object;
>
> if it's dropped on a form, it can control the place where actual
> TComponentClass.Create fired and sends this event. In this case anyone can
> easily do something like:
>
> procedure TForm1.LCLEventsCreateComponent(Sender: TObject; Component:
> TComponent);
> begin
>  if Component is TLabel then
>    with Component as TLabel do
>    begin
>       AutoSize:=False;
>       Layout:=tlCenter;
>    end else
>   if Component is ...
> end;
>
> This method should do exactly the things you described. Although it is a
> form method, it doesn't matter much, it just should be first form to create
> and never-freed. In this case it should work for any form (like
> TApplicationEvents does).

I could then create a global object that sets this handler.
This should be implemented in TReader or in TComponent.AfterCreate, 
so I can do it myself in the classes unit if necessary.

There is only one drawback in this system: it will be called for all created
components. This means that there will be a huge If/then/else, and that
there is only 1 handler possible.

My system will be significantly faster, and is easily controllable on a
per-component basis.

Michael.




More information about the Lazarus mailing list