Do you know why ?
the width property is integer but < 32768 !
you can try with this code but before you must use this component :
- Code: Select all
type TRicScrollBox = class(TScrollBox)
private
FOnHorizontalScroll: TNotifyEvent;
procedure WMHScroll(var Messag: TWMHScroll); message WM_HSCROLL;
public
constructor Create(AOwner: TComponent); override;
Destructor Destroy; Override;
published
property OnHorizontalScroll: TNotifyEvent read FOnHorizontalScroll write FOnHorizontalScroll;
end;
procedure Register;
implementation
constructor TRicScrollBox.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
end;
destructor TRicScrollBox.Destroy;
begin
Inherited Destroy;
end;
procedure TRicScrollBox.WMHScroll(var Messag: TWMHScroll);
begin
inherited;
if Assigned(FOnHorizontalScroll) then FOnHorizontalScroll(Self);
end;
procedure Register;
begin
RegisterComponents('MyDelphi', [TRicScrollBox]);
end;
end.
This is an example :
- Code: Select all
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Grids, UnitRicScrollBox;
type
TForm1 = class(TForm)
RicScrollBox1: TRicScrollBox;
StringGrid1: TStringGrid;
procedure StringGrid1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.StringGrid1Click(Sender: TObject);
var i : integer;
begin
StringGrid1.width := StringGrid1.width *2;
StringGrid1.colcount := StringGrid1.colcount*2;
for i := 1 to StringGrid1.colcount do StringGrid1.Cells[i-1,0] := inttostr(i);
ricscrollbox1.repaint;
Caption := 'Colcount = '+ inttostr(StringGrid1.colcount) + ' / grid.Width = '+inttostr(StringGrid1.width);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
form1.width := 550;
with Ricscrollbox1 do
begin
align := alclient;
Autoscroll := true;
Autosize := false;
end;
with StringGrid1 do
begin
width := clientWidth;
Height := ClientHeight;
rowcount := 1;
colcount := 5;
defaultcolwidth := width div 5;
defaultRowHeight := height div 2;
end;
StringGrid1Click(Self);
end;
end.