ddhcnted.pas
来自「Delphi高级开发指南是开发程序的好帮手」· PAS 代码 · 共 60 行
PAS
60 行
unit DdhCntEd;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
{$R *.DCR}
type
TDdhCountEdit = class(TEdit)
private
FLabel: TLabel;
procedure SetCountLabel (Value: TLabel);
protected
procedure Notification(AComponent: TComponent;
Operation: TOperation); override;
procedure Change; override;
published
property CountLabel: TLabel
read FLabel write SetCountLabel;
end;
procedure Register;
implementation
procedure TDdhCountEdit.SetCountLabel (Value: TLabel);
begin
if Value <> FLabel then
begin
FLabel := Value;
FLabel.Caption := IntToStr (Length (Text));
FLabel.FreeNotification (self);
end;
end;
procedure TDdhCountEdit.Change;
begin
inherited Change;
if Assigned (FLabel) then
FLabel.Caption := IntToStr (Length (Text));
end;
procedure TDdhCountEdit.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited Notification(AComponent, Operation);
if (Operation = opRemove) and (AComponent = FLabel) then
FLabel := nil;
end;
procedure Register;
begin
RegisterComponents('DDHB', [TDdhCountEdit]);
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?