1. 控件TMyEdit 繼承TEdit,請寫出定義語句
2. 修改TMyEdit (繼承於TEdit),使其只接受數字輸入
用DELPHI 实现
2. 修改TMyEdit (繼承於TEdit),使其只接受數字輸入
用DELPHI 实现
解决方案 »
- 怎样在图片上实现坐标定位
- 为什么Delphi版置顶的是Delphi7下载,现在不都到Delphi2007了么?Delphi7有这么经典?
- 如何得到活动界面上的活动Edit,然后往里面填值。
- TADOQuery打开和关闭时会触发什么事件呢?
- 'oookkk' come in only !
- ActiveX之~~~~Windows Media Player 问题1
- 怎样在程序的运行中得到SQL数据库连接的活动用户数?在线等待。
- 求救:多线程教程!!!!
- 请给一个中等规模Delphi消息示例代码,有注释的。
- 调用考勤机DLL函数问题?
- 【bitxunmeng】生日快乐,希望能看到你和她灿烂的笑容!
- 多个edit4的文件拖放问题
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Edit1: TEdit;
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if not (Key in['0'..'9',#8]) then Key:=#0;
end;end.
unit untMyEdit;interfaceuses
Classes, Windows, StdCtrls;type
TMyEdit = class(TEdit)
protected
procedure KeyPress(var Key: Char); override;
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
public
constructor Create(AOwner: TComponent); override;
end;procedure Register;implementationprocedure Register;
begin
RegisterComponents('Samples', [TMyEdit]);
end;procedure TMyEdit.KeyPress(var Key: Char);
begin
if not (Key in ['0'..'9', Chr(VK_BACK), Chr(VK_RETURN), Chr(VK_LEFT), Chr(VK_RIGHT)]) then Key := #0
else
inherited KeyPress(KEY);
end;procedure TMyEdit.KeyDown(var Key: Word; Shift: TShiftState);
begin
if not (Key in [Ord('0')..Ord('9'), VK_BACK, VK_RETURN, VK_LEFT, VK_RIGHT]) then Key := 0
else
inherited KeyDown(Key, Shift);
end;constructor TMyEdit.Create(AOwner: TComponent);
begin
inherited;
Text := '0';
end;end.