关于DELPHI多个窗口的有关问题

关于DELPHI多个窗口的问题
有一个登陆窗口,程序运行时登陆窗口运行,登陆之后打开其他窗口,登陆窗口隐藏,此时点击窗口的关闭按钮时只关闭当前窗口,但是程序无法关闭(登陆窗口仍在运行),如果在当前窗口关闭登陆窗口,整个程序就关闭了。请问一下能不能在当前窗口只关闭登陆窗口,或者点击当前窗口的关闭按钮时关闭登陆窗口。

------解决方案--------------------
正常操作delphi中必须关闭了主窗口Application才会退出。你可以登录窗口成功后释放。当然也可以一下方法处理。
1.Application.Terminate;
2.发送关闭消息给登录窗口.
------解决方案--------------------
1。窗口不要自动生成
2。在工程文件中自己创建,运行登录窗口
3。登录成功则运行其它窗口,否则直接退出

Application.Initialize;
// 系统启动闪现窗口启动
SplashForm := TSplashForm.Create(Application);
SplashForm.Makesplash;

// 测试连接文件是否存在
FileName := ExtractFilePath(Application.ExeName) + 'config.ini';
LinkSetIniFile := TIniFile.Create(FileName);
DBTag := LinkSetIniFile.ReadInteger('DBTag', 'DBTag', 0);
ServerName := Dec(LinkSetIniFile.ReadString('ServerName', 'ServerName', ''));
DBName := Dec(LinkSetIniFile.ReadString('DBName', 'DBName', ''));
UserNames := Dec(LinkSetIniFile.ReadString('UserName', 'UserName', ''));
Password := Dec(LinkSetIniFile.ReadString('Password', 'Password', ''));
LinkSetIniFile.Destroy;

// 检测是否可进行数据库连接
Linktemp := TADOConnection.Create(Application);
Linktemp.LoginPrompt := False;
Linktemp.Close;
case DBTag of
0:
Linktemp.ConnectionString := Format(LinkStrB, [DBName, ServerName]);
1:
Linktemp.ConnectionString := Format(LinkStrA, [Password, UserNames,
DBName, ServerName]);
end;

try
Linktemp.Connected := True;
LinkTag := True;
except
LinkTag := False;
end;
Linktemp.Close;
Linktemp.Free;

// 窗口结束
if not LinkTag then
begin
SplashForm.Close;
SplashForm.Free;
Application.MessageBox('数据库无法联接!请重新安装系统', '系统提示', MB_ICONERROR + MB_OK);
Application.Terminate;
end;

if not Assigned(DMForm) then
DMForm := TDMForm.Create(Application);

Sleep(1500);
SplashForm.Close;
SplashForm.Free;

LogonTag := False;
// 打开人员资料表//
DMForm.Users.Open;
DMForm.Users.First;
if DMForm.Users.IsEmpty then
begin
UserName := 'Administrator';
UserID := 0;
LogonTag := True;
end
else
begin
// 显示登录界面
if not Assigned(SystemLogonForm) then
SystemLogonForm := TSystemLogonForm.Create(Application);
SystemLogonForm.ShowModal;
end;
DMForm.Users.Close;
  
//登录成功
if LogonTag then
begin
Application.Title := '信息管理系统';
Application.CreateForm(TMainForm, MainForm);
Application.Run;
end
else
Application.Terminate;

end.
------解决方案--------------------
Application.Terminate;