📄 focusf.pas
字号:
unit FocusF;
interface
uses
SysUtils, Windows, Messages, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls, ComCtrls;
type
TFocusForm = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
EditFirstName: TEdit;
EditLastName: TEdit;
EditPassword: TEdit;
StatusBar1: TStatusBar;
procedure GlobalEnter(Sender: TObject);
procedure EditFirstNameExit(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
FocusForm: TFocusForm;
implementation
{$R *.DFM}
procedure TFocusForm.GlobalEnter(Sender: TObject);
var
I: Integer;
begin
for I := 0 to ControlCount - 1 do
// if the control is a label
if (Controls [I] is TLabel) and
// and the label is connected to the current edit box
(TLabel(Controls[I]).FocusControl = Sender) then
// copy the text leaving off the initial & character
StatusBar1.SimpleText := 'Enter ' +
Copy (TLabel(Controls[I]).Caption, 2, 1000);
end;
procedure TFocusForm.EditFirstNameExit(Sender: TObject);
begin
if EditFirstName.Text = '' then
begin
// don't let the user get out
EditFirstName.SetFocus;
MessageDlg ('First name is required',
mtError, [mbOK], 0);
end
else if EditFirstName.Text = 'Admin' then
begin
// fill the second edit and jump to the third
EditLastName.Text := 'Admin';
EditPassword.SetFocus;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -