Try this. Start a new Lazarus project. Double-click the main form to generate an OnCreate event handler, and complete the unit as follows:
unit mainUpDown;
{$mode objfpc}{$H+}
interface
uses
Classes, Forms, ComCtrls, Spin;
type
{ TForm1 }
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
spinEdit: TSpinEdit;
upDown: TUpDown;
procedure upDownChangingEx(Sender: TObject; var AllowChange: Boolean;
NewValue: SmallInt; Direction: TUpDownDirection);
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
upDown:=TUpDown.Create(Self);
upDown.Top:=10;
upDown.Left:=10;
upDown.OnChangingEx:=@updownChangingEx;
upDown.Parent:=Self;
spinEdit:=TSpinEdit.Create(Self);
spinEdit.Top:=10;
spinEdit.Left:=upDown.BoundsRect.Right + 10;
spinEdit.Value:=5;
spinEdit.Parent:=Self;
Caption:='UpDown demo';
end;
procedure TForm1.updownChangingEx(Sender: TObject; var AllowChange: Boolean;
NewValue: SmallInt; Direction: TUpDownDirection);
begin
case Direction of
updDown: spinEdit.Value:=spinEdit.Value-1;
updUp: spinEdit.Value:=spinEdit.Value+1;
end;
end;
end.
Then press F9.