unit1.pas

来自「Delphi的函数例子」· PAS 代码 · 共 42 行

PAS
42
字号
unit Unit1;

interface

uses
  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 ['a'..'z',#8,#13]) then
    key := #0
  else
  begin
    if key = #13 then
    begin
      Edit1.Text := Uppercase(copy(Edit1.Text,1,1))+Copy(Edit1.Text,
2,length(Edit1.Text)-1);
    end;
  end;

end;

end.

⌨️ 快捷键说明

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