unit MisFechas;
interface
uses
Controls, StdCtrls, Classes;
type
TFechas = class(TCustomControl)
private
FCampoD: TEdit;
FCampoM: TEdit;
FCampoA: TEdit;
vDia:Byte;
vMes:Byte;
vAni:Integer;
procedure OnChangeClicD(Sender: TObject);
procedure OnChangeClicM(Sender: TObject);
function GetDia:Byte;
procedure SetDia(Value:Byte);
protected
public
constructor Create(AOwner: TComponent); override;
published
property Dia:Byte read GetDia write SetDia;
end;
procedure Register;
implementation
uses Dialogs, SysUtils;
procedure Register;
begin
RegisterComponents('MisComponentes', [TFechas]);
end;
function TFechas.GetDia:Byte;
begin
Result:=vDia;
end;
procedure TFechas.SetDia(Value: Byte);
begin
vDia:=Value;
if (FCampoD.Visible) and (FCampoD.Enabled) then
FCampoD.Text:=IntToStr(vDia);
end;
constructor TFechas.Create(AOwner: TComponent);
begin
inherited;
Width := 85;
Height := 21;
FCampoD := TEdit.Create(Self);
with FCampoD do
begin
SetBounds(0, 0, 22, 21);
Visible := true;
MaxLength:=2;
OnChange := OnChangeClicD;
Parent := Self;
end;
FCampoM := TEdit.Create(Self);
with FCampoM do
begin
SetBounds(22, 0, 22, 21);
Visible := true;
MaxLength:=2;
OnChange := OnChangeClicM;
Parent := Self;
end;
FCampoA := TEdit.Create(Self);
with FCampoA do
begin
SetBounds(44, 0, 40, 21);
Visible := true;
MaxLength:=4;
Parent := Self;
end;
end;
procedure TFechas.OnChangeClicD(Sender: TObject);
begin
if Length(FCampoD.Text)=FCampoD.MaxLength then
try
FCampoM.SetFocus;
except
end;
end;
procedure TFechas.OnChangeClicM(Sender: TObject);
begin
if Length(FCampoM.Text)=FCampoM.MaxLength then
try
FCampoA.SetFocus;
except
end;
end;
end.