帮我看看这段代码怎么写才对!

zsjzwj zsjzwj 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
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.
...全文

相关推荐

评论 12
收藏 已收藏
分享
返回顶部
zsjzwj
Delphi 5,944 成员 262,941 内容