TLama hits the nail in her comments: for some reason, the designer prevents the components from becoming too small. Strange, although 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 indicated by OP, and 100 x 41 here in D7.
Well, since TBevel does not use or publish the AutoSize property, and this property relates to the desired behavior, I decided to stretch its use:
type TSSPacer = class(TBevel) protected procedure SetParent(AParent: TWinControl); override; public constructor Create(AOwner: TComponent); override; procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override; published property Shape default bsSpacer; end; constructor TSSPacer.Create(AOwner: TComponent); begin inherited Create(AOwner); Shape := bsSpacer; end; procedure TSSPacer.SetBounds(ALeft, ATop, AWidth, AHeight: Integer); begin if AutoSize then inherited SetBounds(ALeft, ATop, 8, 8) else inherited SetBounds(ALeft, ATop, AWidth, AHeight); end; procedure TSSPacer.SetParent(AParent: TWinControl); begin AutoSize := (csDesigning in ComponentState) and (Parent = nil) and (AParent <> nil); inherited SetParent(AParent); end;
This works here in D7, but a more robust implementation might be:
private FFixDesignSize: Boolean; procedure TSSPacer.SetBounds(ALeft, ATop, AWidth, AHeight: Integer); begin if FFixDesignSize then begin inherited SetBounds(ALeft, ATop, 8, 8); FFixDesignSize := False; end else inherited SetBounds(ALeft, ATop, AWidth, AHeight); end; procedure TSSPacer.SetParent(AParent: TWinControl); begin FFixDesignSize := (csDesigning in ComponentState) and (Parent = nil) and (AParent <> nil); inherited SetParent(AParent); end;
And to complete this answer with the call stack, dropping this control in the constructor in the form:
- Before SetBounds - After SetBounds - Before SetBounds - After SetBounds - Before SetParent - Before SetBounds - After SetBounds - After SetParent - Before SetBounds - After SetBounds - Before SetParent - After SetParent
But I think you should not rely on this particular order or number of calls: I suspect that this may be different from Delphi versions.