登陆方式设计

1.

 1 program Project1;
 2 
 3 uses
 4   Vcl.Forms,
 5   Unit1 in 'Unit1.pas' {Form1},
 6   Unit2 in 'Unit2.pas' {Form2};
 7 
 8 {$R *.res}
 9 
10 begin
11   Application.Initialize;
12   Application.MainFormOnTaskbar := True;
13   if Login() then
14     Application.CreateForm(TForm1, Form1);
15   Form1.Caption := '登录成功';
16   Application.Run;
17 end.
View Code

2.

 1 unit Unit2;
 2 
 3 interface
 4 
 5 uses
 6   Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
 7   Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
 8 
 9 type
10   TForm2 = class(TForm)
11     Button1: TButton;
12     procedure Button1Click(Sender: TObject);
13   private
14     { Private declarations }
15   public
16     { Public declarations }
17   end;
18 function Login():Boolean; //方法声明
19 var
20   Form2: TForm2;
21 
22 implementation
23 uses Unit1;
24 {$R *.dfm}
25 
26 function  Login():Boolean; //方法定义
27 var
28   FormLogin:TForm2;
29 begin
30 //  FormLogin:=TForm2.Create(nil);
31   Application.CreateForm(TForm2, FormLogin);
32 //  FormLogin:=TForm2.Create(Application);
33   Result := FormLogin.ShowModal = mrOk;
34   FormLogin.Free;
35 end;
36 
37 procedure TForm2.Button1Click(Sender: TObject);
38 begin
39   ModalResult:=mrOK;
40 end;
41 
42 end.
View Code

3.

 1 unit Unit1;
 2 
 3 interface
 4 
 5 uses
 6   Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
 7   Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls;
 8 
 9 type
10   TForm1 = class(TForm)
11     Button1: TButton;
12     Panel1: TPanel;
13     procedure Button1Click(Sender: TObject);
14   private
15     { Private declarations }
16   public
17     { Public declarations }
18   end;
19 
20 var
21   Form1: TForm1;
22 
23 implementation
24 uses Unit2;
25 {$R *.dfm}
26 
27 procedure TForm1.Button1Click(Sender: TObject);
28 begin
29   Caption :=
30   Application.MainForm.Name;
31 end;
32 
33 end.
View Code

 

posted on 2019-01-04 09:03  疯狂delphi  阅读(339)  评论(0编辑  收藏  举报

导航