Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2012-12

TCustomControl.Autosize issue

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Krzysztof

Hi,

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?

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?

Regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20121210/185a36bf/attachment.html>

Reply by email

Felipe Monteiro de Carvalho
to Krzysztof
Krzysztof wrote 5 lines
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

Reply by email

Krzysztof
to Felipe Monteiro de Carvalho
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.

I thought so. I just overrided CalculatePreferredSize method and enumerated child controls for height calculation. Works fine. Thanks -------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20121210/285e3bbf/attachment.html>

Reply by email