Sign in Join

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

Mailing lists / lazarus / 2013-02

AlignControls

6 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

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

Juha Manninen

I am trying to figure out how AlignControls works. The signature is:

  procedure AlignControls(aControl: TControl; var aRect: TRect); override;

What exactly is aControl for? Delphi's documentation says: AControl specifies the control that takes precedence in alignment when other controls have the same Align value. AControl can be nil

Does it mean AControl is Nil when all controls have Align = alNone? The base method TWinControl.AlignControls is huge, over 700 lines, made by "ask".

There is an error in wiki page:
http://wiki.freepascal.org/Autosize_/_Layout
which says:
The layout is applied in the method TWinControl.AlignControls which can be overridden. For example TToolBar overrides that and defines a flow layout where controls that do not fit are put into subsequent lines.

However, TToolBar does not have such method.
There are only 2 components with overridden AlignControls, TScrollingWinControl where it only updates scrollbars, and TControlBar where is does nothing yet.

I am thinking how to use it in TControlBar and maybe in TCoolBar. As you can see I am not very experienced component writer.

Regards,
Juha

Reply by email

Juha Manninen
to Juha Manninen

A related question:
How can I prevent a user from moving controls associated with CoolBar bands at design-time?
I guess I can set the locations of all controls in AlignControls but is there any better way?

Juha

Reply by email

Mattias Gaertner
to Juha Manninen: I am trying to figure out how AlignControls works. The signature is: procedure…

Juha Manninen hat am 1. Februar 2013 um 11:56
geschrieben:

I am trying to figure out how AlignControls works.

It's complicated.

Show quoted text 9 lines
The signature is: procedure AlignControls(aControl: TControl; var aRect: TRect); override; What exactly is aControl for? Delphi's documentation says: AControl specifies the control that takes precedence in alignment when other controls have the same Align value. AControl can be nil Does it mean AControl is Nil when all controls have Align = alNone?

No.

http://wiki.lazarus.freepascal.org/Autosize_/_Layout#TWinControl.AlignControls

Show quoted text 15 lines
The base method TWinControl.AlignControls is huge, over 700 lines, made by "ask". There is an error in wiki page: http://wiki.freepascal.org/Autosize_/_Layout which says: The layout is applied in the method TWinControl.AlignControls which can be overridden. For example TToolBar overrides that and defines a flow layout where controls that do not fit are put into subsequent lines. However, TToolBar does not have such method. There are only 2 components with overridden AlignControls, TScrollingWinControl where it only updates scrollbars, and TControlBar where is does nothing yet.

I updated the entry.

I am thinking how to use it in TControlBar and maybe in TCoolBar. As you can see I am not very experienced component writer.

You are working on an unusual one.

Mattias

Reply by email

Mattias Gaertner
to Juha Manninen: A related question: How can I prevent a user from moving controls associated with CoolBar…

Juha Manninen hat am 1. Februar 2013 um 12:30
geschrieben:

Show quoted text 5 lines
A related question: How can I prevent a user from moving controls associated with CoolBar bands at design-time? I guess I can set the locations of all controls in AlignControls but is there any better way?

Well, your AlignControls should move them anyway, so that would be sufficient.

You can set

Child.ControlStyle:=Child.ControlStyle+[csDesignFixedBounds];

Mattias

Reply by email

Juha Manninen
to Mattias Gaertner
Mattias Gaertner wrote
Well, your AlignControls should move them anyway, so that would be sufficient.

Thanks Mattias, I got it working.

You can set Child.ControlStyle:=Child.ControlStyle+[csDesignFixedBounds];

This had no effect in my tests. The control could still be moved.

Juha

Reply by email

Mattias Gaertner
to Juha Manninen
Show quoted text 11 lines
On Fri, Feb 1, 2013 at 1:47 PM, Mattias Gaertner wrote: > Well, your AlignControls should move them anyway, so that would be sufficient. Thanks Mattias, I got it working. > You can set > Child.ControlStyle:=Child.ControlStyle+[csDesignFixedBounds]; This had no effect in my tests. The control could still be moved.

Fixed.

Mattias

Reply by email