unit uscalebycomctrls;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils,uscaleby,Controls,ComCtrls;

implementation

procedure ListViewScaleBy(const AControl: TControl; const AOrigin,
  ATarget: SizeUint);
var
  j: SizeUint;
  TheCol: TListColumn;
  ListView: TListView;
begin
  ListView:=TListView(AControl);
  //ListView only scales the columns size in report mode
  for j := 0 to ListView.Columns.Count-1 do begin
    TheCol:=ListView.Columns[j];
    TheCol.Width:=TheCol.Width*ATarget div AOrigin;
  end;
end;

procedure StatusBarScaleBy(const AControl: TControl; const AOrigin,
  ATarget: SizeUint);
var
  j: SizeUint;
  ThePanel: TStatusPanel;
  StatusBar: TStatusBar;
begin
  StatusBar:=TStatusBar(AControl);
  //Status only scales the panel width
  for j := 0 to StatusBar.Panels.Count-1 do begin
    ThePanel:=StatusBar.Panels[j];
    ThePanel.Width:=ThePanel.Width*ATarget div AOrigin;
  end;
end;

initialization
  ScaleByRegisterScaler(TListView,@ListViewScaleBy);
  ScaleByRegisterScaler(TStatusBar,@StatusBarScaleBy);

end.

