[Lazarus] TCustomControl.Autosize issue

Felipe Monteiro de Carvalho felipemonteiro.carvalho at gmail.com
Mon Dec 10 23:03:42 CET 2012


On Mon, Dec 10, 2012 at 10:49 PM, Krzysztof <dibo20 at wp.pl> wrote:
> I have own control TMyPanel which inherit from TCustomControl instead of
> TCustomPanel (because I don't want add ExtCtrls unit). My panel has the same
> flags and options like TCustomPanel, but Autosize doesn't work like in
> normal panel. My panel don't account child controls and I can't find code
> responsible for that in TCustomPanel. Any tips?

If you are writing a custom control, then you need to write yourself
code to calculate it's prefered size on autosize. I think that to do
that you need to override the routine PreferredSize or something
similar. And there implement the calculation like you want.

> BTW: Why TCustomPanel is in ExtCtrls unit? I think that this important
> control which is the base for many other controls, should be in StdCtrls (it
> is on standard palette). Reason is delphi compability?

This makes no sense. A control is not more important because he is in
unit x or y. Moving controls from one unit to the other is not a good
idea as it changes nothing and causes backwards compatibility issues.

-- 
Felipe Monteiro de Carvalho




More information about the Lazarus mailing list