⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ddhcnted.pas

📁 Delphi高级开发指南是开发程序的好帮手
💻 PAS
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -