Using Delphi 6 Prof.
I created a bevel component for separation.
Because I used spacers with 8 pixel (width x height) I thought that I create this component, and when I put it on a Form, I need only to set Align - and that's all.
type
TSSpacer = class(TBevel)
public
constructor Create(aOwner: TComponent); override;
published
//property Width default 8;
//property Height default 8;
property Shape default bsSpacer;
end;
constructor TSSpacer.Create(aOwner : TComponent);
begin
inherited Create(aOwner);
Shape := bsSpacer;
Width := 8;
Height := 8;
end;
But when I use this code (with or without "defaults") the result is 140 x 41 pixels in the IDE.
So why does it not size to 8 x 8? And what is also interesting: the default TBevel is 50 x 50.
What causes this resizing?
TLama hits the nail in his comments: somehow the designer prevents components from becoming too small. Strange though that the designer does not set this minimum size (10 x 10), but instead seems to randomly set the size to arbitrary values: 140 x 41 in D6 as stated by OP, and 100 x 41 here in D7.
Well, since TBevel does use nor publish the
AutoSize
property, and that property name kind of relates to wished behaviour, I chose to stretch its use:This works here in D7, but a more reliable implementation might be:
And to complete this answer with a call stack of dropping this control in the designer on a form:
But I think you should not rely on this specific order or number of calls: I suspect it might differ between Delphi versions.