📄 unit1.pas
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, ExtCtrls, Buttons, ExtDlgs;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Bevel1: TBevel;
Label3: TLabel;
Edit3: TEdit;
ProgressBar1: TProgressBar;
StatusBar1: TStatusBar;
Label4: TLabel;
Button1: TButton;
Edit4: TEdit;
Label5: TLabel;
ComboBox1: TComboBox;
Image1: TImage;
Panel1: TPanel;
Label6: TLabel;
Label7: TLabel;
RadioGroup1: TRadioGroup;
Edit5: TEdit;
Label8: TLabel;
Memo1: TMemo;
Button2: TButton;
Button3: TButton;
Label9: TLabel;
GroupBox1: TGroupBox;
CheckBox1: TCheckBox;
CheckBox2: TCheckBox;
Image2: TImage;
ListBox1: TListBox;
Label10: TLabel;
Button4: TButton;
Button5: TButton;
ListBox2: TListBox;
BitBtn1: TBitBtn;
Bevel2: TBevel;
OpenPictureDialog1: TOpenPictureDialog;
Image3: TImage;
Timer1: TTimer;
FontDialog1: TFontDialog;
Button6: TButton;
procedure Button2Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Edit1KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Edit2KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Edit3KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Edit4KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Edit5KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
const
Key_Enter=13;
Key_ArrowDown=40;
Key_ArrowUp=38;
Key_ArrowLeft=37;
Key_ArrowRight=39;
Key_Home=36;
Key_End=35;
implementation
{$R *.dfm}
procedure TForm1.Button2Click(Sender: TObject);
begin
if Panel1.Visible=true
then
begin
Panel1.Visible:=false;
Form1.ClientWidth:=423;
end
else
begin
panel1.Visible:=true;
Form1.ClientWidth:=819;
end;
end;
procedure TForm1.Button4Click(Sender: TObject);
var
i:integer;
liststr:string;
listcount:integer;
begin
listcount:=ListBox1.Items.Count-1;
for i:=0 to listcount do
if ListBox1.Selected[i] then
begin
liststr:=ListBox1.Items.Strings[i];
ListBox2.Items.Add(liststr);
end;
for i:=listcount downto 0 do
if ListBox1.Selected[i] then
ListBox1.Items.Delete(i);
end;
procedure TForm1.Button5Click(Sender: TObject);
var
i:integer;
liststr:string;
listcount:integer;
begin
listcount:=ListBox2.Items.Count-1;
for i:=0 to listcount do
if ListBox2.Selected[i] then
begin
liststr:=ListBox2.Items.Strings[i];
ListBox1.Items.Add(liststr);
end;
for i:=listcount downto 0 do
if ListBox2.Selected[i] then
ListBox2.Items.Delete(i);
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
OpenPictureDialog1.Execute;
if OpenPictureDialog1.FileName = ''
then
else
begin
image3.Picture.LoadFromFile(OpenPictureDialog1.FileName);
image3.Stretch:=true;
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
if Edit1.Text='' then ShowMessage('用户名不能为空')
else if Edit2.Text='' then ShowMessage('密码不能为空')
else if Edit3.Text='' then ShowMessage('确认密码不能为空')
else if Edit4.Text='' then ShowMessage('Email不能为空')
else
begin
ProgressBar1.Position:=0;
Timer1.Enabled:=true;
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
ProgressBar1.Position:=ProgressBar1.Position+10;
if ProgressBar1.Position=100 then
begin
Timer1.Enabled:=false;
progressbar1.Position:=0;
showmessage('提交成功');
end
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if Edit1.Text='' then ShowMessage('请先输入用户名')
else ShowMessage('用户名可以使用');
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
FontDialog1.Execute;
Edit1.Font:=FontDialog1.Font;
Edit2.Font:=FontDialog1.Font;
Edit3.Font:=FontDialog1.Font;
Edit4.Font:=FontDialog1.Font;
Edit5.Font:=FontDialog1.Font;
Memo1.Font:=FontDialog1.Font;
end;
procedure TForm1.Edit1KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (Key=Key_Enter) or (Key=Key_ArrowDown) then
Edit2.SetFocus;
if (ssCtrl in Shift) and (Key=Key_ArrowRight) and (Panel1.Visible=true) then
Edit5.SetFocus;
end;
procedure TForm1.Edit2KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (Key=Key_Enter) or (Key=Key_ArrowDown) then
Edit3.SetFocus;
if (ssCtrl in Shift) and (Key=Key_ArrowRight) and (Panel1.Visible=true) then
Edit5.SetFocus;
if (Key=Key_ArrowUp) then
Edit1.SetFocus;
end;
procedure TForm1.Edit3KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (Key=Key_Enter) or (Key=Key_ArrowDown) then
Edit4.SetFocus;
if (ssCtrl in Shift) and (Key=Key_ArrowRight) and (Panel1.Visible=true) then
Edit5.SetFocus;
if (Key=Key_ArrowUp) then
Edit2.SetFocus;
end;
procedure TForm1.Edit4KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (Key=Key_Enter) or (Key=Key_ArrowDown) then
Button3.SetFocus;
if (ssCtrl in Shift) and (Key=Key_ArrowRight) and (Panel1.Visible=true) then
Edit5.SetFocus;
if (Key=Key_ArrowUp) then
Edit3.SetFocus;
end;
procedure TForm1.Edit5KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (Key=Key_Enter) or (Key=Key_ArrowDown) then
Button3.SetFocus;
if (ssCtrl in Shift) and (Key=Key_ArrowLeft) then
Edit1.SetFocus;
if (Key=Key_ArrowUp) then
Edit4.SetFocus;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -