DDHNUMED.PAS
unit DdhNumEd;
interface
uses
SysUtils, Classes, Graphics, Controls, StdCtrls;
{$R *.DCR}
type
TDdhNumEdit = class (TCustomEdit)
private
fInputError: TNotifyEvent;
protected
function GetValue: Integer;
procedure SetValue (Value: Integer);
public
procedure KeyPress (var Key: Char); override;
constructor Create (Owner: TComponent); override;
published
property OnInputError: TNotifyEvent
read fInputError write fInputError;
property Value: Integer
read GetValue write SetValue default 0;
property AutoSelect;
property AutoSize;
property BorderStyle;
property CharCase;
property Color;
property Ctl3D;
property DragCursor;
property DragMode;
property Enabled;
property Font;
property HideSelection;
property MaxLength;
property OEMConvert;
property ParentColor;
property ParentCtl3D;
property ParentFont;
property ParentShowHint;
property PasswordChar;
property PopupMenu;
property ReadOnly;
property ShowHint;
property TabOrder;
property TabStop;
property Visible;
property OnChange;
property OnClick;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
end;
procedure Register;
implementation
constructor TDdhNumEdit.Create (Owner: TComponent);
begin
inherited Create (Owner);
SetValue (0);
end;
function TDdhNumEdit.GetValue: Integer;
begin
// set to 0 in case of error
Result := StrToIntDef (Text, 0);
end;
procedure TDdhNumEdit.SetValue (Value: Integer);
begin
Text := IntToStr (Value);
end;
procedure TDdhNumEdit.KeyPress (var Key: Char);
begin
if not (Key in ['0'..'9']) and not (Key = #8) then
begin
Key := #0;
if Assigned (fInputError) then
fInputError (self);
end;
end;
procedure Register;
begin
RegisterComponents ('DDHB', [TDdhNumEdit]);
end;
end.
Generated by PasToWeb, a tool by Marco Cantù.