[Lazarus] New autosize is better than me

Mattias Gärtner nc-gaertnma at netcologne.de
Fri Apr 23 12:12:08 CEST 2010


Zitat von zeljko <zeljko at holobit.net>:

> [...]
>> > 3.It does not work correct with new autosize.
>>
>> Formerly the OnResize was often triggered after the LCL did some
>> autosizing, so for simple form layouts the above worked sometimes. The
>> OnResize is now triggered earlier. I can change it to trigger the event
>> later, but as OnResize can trigger new autosizes, it can't be
>> guaranteed that it will be the final event.
>> The right solution is to use the TStringGrids OnResize.
>
> AFAIK, OnResize() isn't in Delphi order.In Delphi OnResize is triggered after
> OnShow(), with LCL it's triggered before OnShow().
> Would be great if all OnResize() are postponed (when real resize is  
> happened), and sent all at once when parent and all children are  
> resized (only when form is resizing).

1. If the bounds are changed after the form became visible, you will  
see flicker. Some widgetsets/windowmanagers combines them and you can  
not see it. I heard that this is often the case under windows. But see  
Martin's Mail, he sees every window move as flicker. Maybe that is why  
the VCL didn't fix it. That's why OnResize comes before OnShow in LCL.

2. OnResize is often used to resize controls. So triggering it after  
real resize would trigger another real resize. That would cause flicker.


>> I will change the event so that it works for some simple cases,
>> but I recommend that you fix your code.
>
> Yes, I'll do that but cannot do it now, I need few days maybe few weeks to
> refactor all forms where I use OnResize().

You know, I tell people since 10 years that the VCL OnResize misuses  
are not portable.


>> > I have not enough time to investigate what's wrong but I know that my
>> > tstringgrid columns aren't resized in form's OnResize event in case of
>> > new autosize.Probably resize events are in opposite order so
>> > Form.OnResize is triggered first but children are not resized yet. Yes, I
>> > know that you wrote somewhere that we should use OnResize() for each
>> > control we want to track, but what should I do now with my project which
>> > have > 400 forms, open each form add OnResize to each control I need to
>> > resize ?
>>
>> I know what you mean.
>> But also think about the many new forms that are created and the many
>> users who wants a reliable and fast LCL. It can not be guaranteed that
>> form's OnResize comes after all the children are resized (unless it
>> triggers far too often and then we get bug reports). And the later
>> OnResize is triggered the more overhead it creates.
>
> Of course that I'm on LCL side, but as I mentioned before - cannot use new
> autosize at the moment , and praying God for OldAutoSize not broken at some
> stage until I refactor my projects.

OTOH we need good bug reports.

Mattias







More information about the Lazarus mailing list