帮我看看这段代码怎么写才对!
unit EditEH;
interface
uses
Windows, Messages, SysUtils, Classes, Controls, StdCtrls;
type
TStyleArray =(saFloat, saInt, saIP, saStr);
TEditEH = class(TEdit)
private
{ Private declarations }
FStyle : TStyleArray;
procedure SetText(const value: TStyleArray);
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
property Style : TStyleArray read FStyle write SetText;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('MyVcl', [TEditEH]);
end;
procedure TEditEH.SetText(const value: TStyleArray);
begin
if FStyle = value then exit
else FStyle := value;
Invalidate;
end;
procedure TEditEH.KeyDown(var Key: Word; Shift: TShiftState);
begin
inherited KeyDown(Key, Shift);
if FStyle=saInt then
begin
if not(key in [48..57,8]) then
begin
key := 0;
end;
end
else if FStyle=saFloat then
begin
if not(key in [46,48..57,8]) then
begin
key := 0;
end;
end
else if FStyle=saIP then
begin
end;
end;
end.