How to overcome the BorderWitdth property error

BorderWidth - Error in components property

Por Vladimir S. <shvetadvipa@mtu-net.ru>

InstallAWARE - MSI without rocket science

If you wish to use the BorderWidth property, be careful. It's very strange, but Borland made a mistake in almost all components that have this property. For example look at the picture:

border.gif

You can see ProgressBars with various BorderWidth values. The height of the ProgressBars in all cases is 16.

If you wish to correct this error see this example for a ProgressBar. You have to make changes in COMCTRLS.PAS like this:

interface

...

TProgressBar = class(TWinControl)
private
  ...
  FBorderWidth: TBorderWidth;
  ...
  procedure SetBorderWidth(Value: TBorderWidth);
  ...
published
  ...
  property BorderWidth: TBorderWidth read FBorderWidth
                                     write SetBorderWidth;
  ...

...

implementation

...

constructor TProgressBar.Create(AOwner: TComponent);
begin
  ...
  FBorderWidth := inherited BorderWidth;
  ...
end;

procedure TProgressBar.SetBorderWidth(Value: TBorderWidth);
begin
  if Value > (Height div 2)-3 then
    raise Exception.CreateFmt('Error: BorderWidth have to less %d',
      [(Height div 2)-3]);
  if Value <> inherited BorderWidth then begin
    inherited BorderWidth := Value;
    FBorderWidth := inherited BorderWidth;
  end;
end;

...

You can use this patch in all the components that have a BorderWidth property.

JfControls Library - for Delphi and C++ Builder