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

📄 clearall.pas

📁 集成酒店桑拿食管管理的完整程序
💻 PAS
字号:

{*******************************************************}
{                                                       }
{   我设计的一个控件用于将Form上的所有TEdit和TMemo清空  }
{   只要调用Clear方法即可。                             }
{                                                       }
{   许国华                                              }
{   EMail:      nick_xu@sina.com                        }
{  个人主页:   go.163.com/~xuguohua                    }
{                                                       }
{*******************************************************}

unit ClearAll;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ComCtrls, StdCtrls;

type
  TClearAll = class(TComponent)
  private
    { Private declarations }
  protected
    { Protected declarations }
    function GetForm: TForm;
  public
    { Public declarations }
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    procedure Clear;
  published
    { Published declarations }
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Nick''s VCL', [TClearAll]);
end;

constructor TClearAll.Create(AOwner: TComponent);
begin
  inherited;
end;

destructor TClearAll.Destroy;
begin
  inherited;
end;

function TClearAll.GetForm: TForm;
begin
  if Owner is TCustomForm then
    Result := TForm(Owner as TCustomForm)
  else
    Result := nil;
end;

procedure TClearAll.Clear;
var
  I: Integer;
  OwnerForm: TForm;
begin
  if Owner is TCustomForm then
  begin
    OwnerForm := TForm(Owner as TCustomForm);
    if OwnerForm <> nil then
    begin
      for I := 0 to OwnerForm.ComponentCount - 1 do
      begin
        if OwnerForm.Components[I] is TEdit then
          (OwnerForm.Components[I] as TEdit).Clear;
        if OwnerForm.Components[I] is TMemo then
          (OwnerForm.Components[I] as TMemo).Lines.Clear;
        if OwnerForm.Components[I] is TComboBox then
          (OwnerForm.Components[I] as TComboBox).text:='';
        if OwnerForm.Components[I] is TRichEdit then
          (OwnerForm.Components[I] as TRichEdit).Lines.Clear;
      end;
    end;
  end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -