I must disagree with you there.

I have a number of controls that I want to align to the top, not to the
client, aligning to the client is not really a lot of use to me; although
still a valid option I think.

I have a number of text displaying controls that I want aligned to the top
like this

Text Control
Bevel Control
Text Control
Check Box Group Control
Bevel Control
Panel Control

I would like these controls to look natural, and no be right up to the edges
of the scroll box. I have come up with a method that works for me anyway.

the scroll box color is ClWindow

I use a panel aligned to the top, its color is clWindow; I then put a panel
in that control aligned to the client.

My text controls are custom written so I altered them to print inside
further so thats OK.

The checkbox group control writes inside anyway so that looks OK.

The bevel is the only one that I did not adjust but that looks OK too.

All of the text and check box group controls have their height dynamically
altered so that they look good and do not have any wasted space around them.

Chris




-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
Behalf Of Dennis Chuah
Sent: Thursday, August 26, 1999 11:27 AM
To: Multiple recipients of list Delphi
Subject: RE: [DUG]: AlignControl does not work in TScrollBox



Chris,

Aligning on a scroll box does not make much sense.  Imagine if you have one
control aligned to alClient.  This is telling the VCL code to align the
control to the entire client region of the scrollbox.  On the other hand,
the client area of the scroll box is dynamically adjusted to fit in all
child controls!  I.e., you have a design concept problem.

The solution is to place the TPanel on the scroll box, size the panel to fit
your requirements.  Now, all controls will align on the TPanel, while you
can use the scrollbox to scoll hidden controls into view.  The only thing
that does not work in this scheme is the ScrollToView method.  You will need
to override that and hack it so that it knows about child controls on the
panel.

Hope this helps.
Dennis.

> I have a need to create a new TScrollBox control that will
> allow my to align
> child controls using a user defined border width. I need to
> have a space
> around any aligned control of 5 pixels on the left, right,
> top & bottom
> edges of the scroll box.
>
> Below is the code I have, and then below that is the same
> code for a custom
> Tpanel. The code for the TPanel works fine, but the scrollbox
> just ignores
> the code I have included and uses a border of nothing when
> aligning the
> child controls.
>
>
> unit AdrockScrollBox;
>
> interface
>
> uses
>   Windows, Messages, SysUtils, Classes, Graphics, Controls,
> Forms, Dialogs;
>
> type
>   TAdrockScrollBox = class(TScrollBox)
>   private
>     FBorderWidth: Integer;
>     procedure SetBorderWidth(const Value: Integer);
>     { Private declarations }
>   protected
>     { Protected declarations }
>   public
>     { Public declarations }
>     Constructor Create(Aowner : TComponent); override;
>     Procedure   AlignControls(AControl: TControl; var Rect: TRect);
> override;
>   published
>     { Published declarations }
>     property BorderWidth : Integer read FBorderWidth write
> SetBorderWidth
> default 5;
>   end;
>
> procedure Register;
>
> implementation
>
>
> Procedure TAdrockScrollBox.AlignControls(AControl: TControl; var Rect:
> TRect);
> begin
>   InflateRect(Rect, -BorderWidth, -BorderWidth);
>   inherited AlignControls(AControl, Rect);
> end;
>
> constructor TAdrockScrollBox.Create(Aowner: TComponent);
> begin
>   Inherited Create(Aowner);
>   FBorderWidth := 5
> end;
>
> procedure TAdrockScrollBox.SetBorderWidth(const Value: Integer);
> begin
>   FBorderWidth := Value;
>   Realign;
>   Invalidate;
> end;
>
> procedure Register;
> begin
>   RegisterComponents('Adrock', [TAdrockScrollBox]);
> end;
>
> end.
> =======================================================
>
> unit AdrockPanelX;
>
> interface
>
> uses
>   Windows, Messages, SysUtils, Extctrls,Classes, Graphics,
> Controls, Forms,
> Dialogs;
>
> type
>   TAdrockPanelXYZ = class(Tpanel)
>   private
>     FBorderWidth: Integer;
>     procedure SetBorderWidth(const Value: Integer);
>     { Private declarations }
>   protected
>     { Protected declarations }
>   public
>     { Public declarations }
>     Constructor Create(Aowner : TComponent); override;
>     Procedure   AlignControls(AControl: TControl; var Rect: TRect);
> override;
>   published
>     { Published declarations }
>     property MyBorderWidth : Integer read FBorderWidth write
> SetBorderWidth
> default 5;
>   end;
>
> procedure Register;
>
> implementation
>
>
> Procedure TAdrockPanelXYZ.AlignControls(AControl: TControl; var Rect:
> TRect);
> begin
>   InflateRect(Rect, -MyBorderWidth, -MyBorderWidth);
>   inherited AlignControls(AControl, Rect);
> end;
>
> constructor TAdrockPanelXYZ.Create(Aowner: TComponent);
> begin
>   Inherited Create(Aowner);
>   FBorderWidth := 5
> end;
>
> procedure TAdrockPanelXYZ.SetBorderWidth(const Value: Integer);
> begin
>   FBorderWidth := Value;
>   Realign;
>   Invalidate;
> end;
>
> procedure Register;
> begin
>   RegisterComponents('Adrock', [TAdrockPanelXYZ]);
> end;
>
> end.
>
> --------------------------------------------------------------
> -------------
>     New Zealand Delphi Users group - Delphi List -
> [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
>

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to