看看下面的例子:
工程文件中:
program Mdiapp;
uses
Forms,
Main in 'MAIN.PAS' {MainForm},
Childwin in 'CHILDWIN.PAS' {MDIChild},
About in 'about.pas' {AboutBox},
Unit1 in 'Unit1.pas' {Form1};
{$R *.RES}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Form1.Showmodal;
if not Form1.FRight then
Application.Terminate
else
Form1.Free;
Application.CreateForm(TMainForm, MainForm);
Application.CreateForm(TAboutBox, AboutBox);
Application.Run;
end.
登录窗口:
我只用一个Edit来判断是否可以登录,你可以加入连接数据库的部分.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
FRight : boolean;
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
FRight := False;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if Edit1.Text = 'me' then
FRight := True
else
FRight := False;
Close;
end;
end.