我先做了一个main.pas 后做了一个login.pas ,现在的情况是执行程序时,最前面显示的是login页,但后面main页也显示,不用输入用户名密码,直接点击右上角的关闭就可以直接进入main页,没有起到登陆的做用,我在main.pas写了
procedure Tmain.FormActivate(Sender: TObject);
begin
Login.Showmodal;
end;
我想实现运行程序时,先显示"登陆"页,而后面什么都没有,不输入密码就进入不了系统,
请各位帮助,先谢谢了!!
procedure Tmain.FormActivate(Sender: TObject);
begin
Login.Showmodal;
end;
我想实现运行程序时,先显示"登陆"页,而后面什么都没有,不输入密码就进入不了系统,
请各位帮助,先谢谢了!!
解决方案 »
- 添加数据后如何刷新from1的listView数据 问题,在线等....
- 菜鸟问题,如何阻止form1运行?请大人来看看!!
- 大家发过来的,我都调试了,都是错误的,有人帮帮我吗
- 如何让DBGrid刷新后,记录位置仍旧是刷新前的位置。
- 高分请教语音查询系统中有关语音卡功能封装成.DLL的问题?
- 各位大侠有好用的控制edit控制输入的控件吗?(maskEdit太不方便了@_@)
- TClientDataSet分布式读取数据时出现错误(cds.open时成员不存在)
- 管理系统编译问题,请帮忙解决
- 如何隐藏和显示工具栏?
- 求助!谁知道delphi6.163安装时需输入的serial number和authorization key!
- 假小子有点问题,请高手上了,来着给分了
- 天啊。中国的程序员令人堪忧。怎都如此的菜。这么简单的问题都不会。分数是白放了。哎。
procedure Tmain.FormActivate(Sender: TObject);
begin
if Login.Showmodal=mrcancel then
Application.terminal;
end;
点关闭或取消则在login窗口close事件中加入main.close;不就行了。
在项目文件中写,如begin
Application.Initialize;
Application.CreateForm(TLoginForm,LoginForm);
if LoginForm.ShowModal=mrOK then
Application.CreateForm(TMainForm, MainForm);
else
Application.Terminate;
Application.Run;
end.
象这种登陆页面一定要在工程文件里写才叫专业!
Application.Initialize;
Logon := TLogon.Create(Application);
if Logon.ShowModal = mrOK then
begin
logon.Free;
Application.CreateForm(TForm1, Form1);
end
else
Application.Terminate; Application.Run;
end.
begin
Application.Initialize;
Logon := TLogon.Create(Application);
if Logon.ShowModal = mrOK then
begin
logon.Free;
Application.CreateForm(TForm1, Form1);
end
else
Application.Terminate; Application.Run;
end.
program splash;uses
Forms,
MainFrm in 'MainFrm.pas' {MainForm},
SplashFrm in 'SplashFrm.pas' {SplashForm};{$R *.RES}
begin
Application.Initialize;
{ Create the splash screen }
SplashForm := TSplashForm.Create(Application);
SplashForm.Show; // Display the splash screen
SplashForm.Update; // Update the splash screen to ensure it gets drawn { This while loop simply uses the TTimer component on the SplashForm
to simulate a lengthy process. }
while SplashForm.tmMainTimer.Enabled do
Application.ProcessMessages; Application.CreateForm(TMainForm, MainForm);
SplashForm.Hide; // Hide the splash screen
SplashForm.Free; // Free the splash screen
Application.Run;
end.
单元1
unit MainFrm;interfaceuses
SysUtils, Windows, Messages, Classes, Graphics, Controls, Forms, Dialogs;type
TMainForm = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
end;var
MainForm: TMainForm;implementation{$R *.DFM}end.
单元2
unit SplashFrm;interfaceuses
SysUtils, Windows, Messages, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls;type
TSplashForm = class(TForm)
imgSplash: TImage;
lbl1: TLabel;
lbl2: TLabel;
lbl3: TLabel;
tmMainTimer: TTimer;
procedure tmMainTimerTimer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
SplashForm: TSplashForm;implementation{$R *.DFM}procedure TSplashForm.tmMainTimerTimer(Sender: TObject);
begin
tmMainTimer.Enabled := False;
end;end.
输入用户名和密码后
main.showm;
program Project1;uses
Forms,
Controls,
Unit1 in 'Unit1.pas' {Form1},
Unit2 in 'Unit2.pas' {Logon};{$R *.res}begin
Application.Initialize;
Logon := TLogon.Create(Application);
if Logon.ShowModal = mrOK then
begin
logon.Free;
Application.CreateForm(TForm1, Form1);
end
else
Application.Terminate; Application.Run;
end.
[Error] STUDENT.DPR(17): Undeclared identifier: 'mrOK'
[Error] STUDENT.DPR(24): ';' not allowed before 'ELSE'
[Error] STUDENT.DPR(27): Record, object or class type required
请问我哪错了呀!!
Application.Initialize;
Application.CreateForm(TLoginForm,LoginForm);
if LoginForm.ShowModal=mrOK then
Application.CreateForm(TMainForm, MainForm) ///把这把分号去掉
else
Application.Terminate;
Application.Run;
end.
[[Error] STUDENT.DPR(17): Undeclared identifier: 'mrOK'
代码如下
begin
Application.Initialize;
Application.CreateForm(Tf_Login,f_Login);
if f_Login.Showmodal = mrOK then
Application.CreateForm(Tf_Main, f_Main)
else
Application.Terminate;
Application.Run;
end.请帮助??