[Lazarus] Strange behaviour of TCustomEditButton ancesters

Martin Frb lazarus at mfriebe.de
Sat Mar 12 23:05:08 CET 2016

On 12/03/2016 20:20, Frans wrote:
> I do understand what you mean, but I do not think that is th case.
> I send my test program, it's very simple.
Did a quick test.
When first time hit TForm1.TabSheet2Show
     FileNameEdit1.FEDIT.FBOUNDSREALIZED : record RECT {  LEFT = 0, TOP 
= 0,   RIGHT = 80,   BOTTOM = 23 }

The Tab has the correct Size (and it has a handle too), the edit does 
not yet have the final size.

The 2nd time
     FileNameEdit1.FEDIT.FBOUNDSREALIZED : record RECT {  LEFT = 0, TOP 
= 0,   RIGHT = 406,   BOTTOM = 21 }

This is because sizes (such as in result of anchors, align, ...) are 
only applied when it makes sense (not sure, parent visible, handle 
created, ....). In fact they probably need a handle, for the proper 
clientrect. And the tab-page only gets a handle when first shown.

I dont know at which time AUTOSIZINGLOCKCOUNT  is set (this avoids doing 
the resize multiple times). Maybe it should be cleared by the time of 
the event. But it is not.

> Op 12-03-2016 om 20:59 schreef Martin Frb:
>> I dont have the "how to fix", but it looks like the first time you 
>> call SetFocus is before the tab got created, (or at least before it 
>> gets its true size). At that time the tab will have a dummy size 
>> (maybe 200 pixel width).
>> The SetFocus may or may not create those handles, but the size is 
>> likely not yet set. So the content of the edit is "scrolled".
>> It could also be, that it is created, but the autosize lock is still 
>> on, deferring the initial resize.

More information about the Lazarus mailing list