我做了一个登陆窗体,用户名和密码正确,然后出现主窗体。我的index窗体是fsmdiform的。担当我进去后,却不能执行原来可以操作的设备管理了。错误提示
access error.....no current mdiform is active....
登陆按钮如下:ADOConnection1.Connected:=true;
with adoquery1 do
begin
close;
sql.Clear;
SQL.add('select * from password ');//+edit1.Text+'=序号 and '+edit2.Text+'=序号');
Sql.add('where 姓名=:p1 ');
Sql.add(' and 密码=:p2 ');
Parameters.ParamByName('p1').Value:=edit1.Text;
Parameters.ParamByName('p2').Value:=edit2.Text;
prepared;
open;
end;
if adoquery1.RecordCount=1 then
begin
//showmessage('欢迎你');
application.creatform(Tindex.index);//是不是这里错误了/如何该?
index.Show;
index.Visible:=true;
end
else
begin
showmessage('对不起!用户名或者密码错误');
edit1.SetFocus;
end;
end;
access error.....no current mdiform is active....
登陆按钮如下:ADOConnection1.Connected:=true;
with adoquery1 do
begin
close;
sql.Clear;
SQL.add('select * from password ');//+edit1.Text+'=序号 and '+edit2.Text+'=序号');
Sql.add('where 姓名=:p1 ');
Sql.add(' and 密码=:p2 ');
Parameters.ParamByName('p1').Value:=edit1.Text;
Parameters.ParamByName('p2').Value:=edit2.Text;
prepared;
open;
end;
if adoquery1.RecordCount=1 then
begin
//showmessage('欢迎你');
application.creatform(Tindex.index);//是不是这里错误了/如何该?
index.Show;
index.Visible:=true;
end
else
begin
showmessage('对不起!用户名或者密码错误');
edit1.SetFocus;
end;
end;
cannot creat form,no mdi forms are cyrrently active.
2。hide
1.MDIform设置成主窗体
什么意识?
我是先出现登陆窗体,再进入到主窗体啊!
var
Form1: TForm1;
Function CreateFirst:boolean;
implementation{$R *.dfm}
Function CreateFirst:boolean;
begin
With Tform1.Create(Application) do
result:= showmodal = mrOK ;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Hide;
end;procedure TForm1.Button2Click(Sender: TObject);
begin
//你自己的验证可以加到这个位置..或写成一个function
if 验证通过 then
ModalResult:=MrOK
else
Modalresult:=MrCancel;
end;
/////////////////////////工程文件代码////////////////////////////
Application.Initialize;
if CreateFirst then
Application.CreateForm(TMainForm, MainForm);
Application.Run;
///注在project option->Forms面板中要将mdiform设置为主窗体.
///将登录窗设置为Available Forms.......................
我试了一下,应该可以,但是从输入密码正确,到主窗体出现,好像很慢,这是为啥?还有就是
/////////////////////////工程文件代码////////////////////////////
Application.Initialize;
if CreateFirst then
Application.CreateForm(TMainForm, MainForm);
Application.Run;
这段代码加道朱窗体的什么位置?
Application.CreateForm(TForm1, Form1);
Application.CreateForm(Tzuzhijigou, zuzhijigou);
Application.CreateForm(Trenyuanxinxi, renyuanxinxi);
Application.CreateForm(Tshebeileibie, shebeileibie);
Application.CreateForm(Tjixieshebeifengji, jixieshebeifengji);
Application.CreateForm(Tjixieshebeikapian, jixieshebeikapian);
Application.CreateForm(Tjixieshebeizhilengji, jixieshebeizhilengji);
Application.CreateForm(Tjixieshebeiluoxuanbeng, jixieshebeiluoxuanbeng);
Application.CreateForm(Tdonglishebeidianhanji, donglishebeidianhanji);
Application.CreateForm(Tdonglishebeidiandongji, donglishebeidiandongji);
Application.CreateForm(Tyushushebeichangleicheliang, yushushebeichangleicheliang);
Application.CreateForm(Tdonglishebeigaoyapan, donglishebeigaoyapan);
Application.CreateForm(Tgudingzichanjixietaizhang, gudingzichanjixietaizhang);
Application.CreateForm(Tdonglishebeibianyaqi, donglishebeibianyaqi);
Application.CreateForm(Tdonglishebeidiyapan, donglishebeidiyapan);
Application.CreateForm(Tdonglishebei35kvyishangpileiqihuganqi, donglishebei35kvyishangpileiqihuganqi);
Application.CreateForm(Tdonglishebei35kvyishangkaiguandaozha, donglishebei35kvyishangkaiguandaozha);
Application.CreateForm(Ttezhongshebeiyalirongqi, tezhongshebeiyalirongqi);
Application.CreateForm(Ttezhongshebeiguolu, tezhongshebeiguolu);
Application.CreateForm(Ttezhongshebeiqizhongshebei, tezhongshebeiqizhongshebei);
Application.CreateForm(Tchuandaoshebeidianlan, chuandaoshebeidianlan);
Application.CreateForm(Tgudingzichandianqiyilanbiao, gudingzichandianqiyilanbiao);
Application.CreateForm(Tgudingzichanjiangouzhuwubiao, gudingzichanjiangouzhuwubiao);
Application.CreateForm(Tshebeixianzhi, shebeixianzhi);
Application.CreateForm(Tshebeibaofei, shebeibaofei);
Application.CreateForm(Tshebeidiaobo, shebeidiaobo);
Application.CreateForm(Tshebeijianxiu, shebeijianxiu);
Application.CreateForm(Tchuandaoshebeuguandao, chuandaoshebeuguandao);
Application.CreateForm(Ttezhongshebeiguolufujian, tezhongshebeiguolufujian);
Application.CreateForm(Txiugaimima, xiugaimima);
Application.CreateForm(Tyonghuguanli, yonghuguanli);
Application.Run;
end.
1.建议你用到该窗体时再创建.
project-option-forms面板,把开始不需要显示得窗体从auto-create移到右面的Available Forms框中~
2.
这样添加就可以了
Application.Initialize;
if CreateFirst then
begin
Application.CreateForm(TForm1, Form1);
Application.CreateForm(Tzuzhijigou, zuzhijigou);
......
Application.Run;
end
else
Application.Terminate;
3.close提示什么错误?
直接写Modalresult:=MrCancel;
或者hide就可以le
begin
ADOConnection1.Connected:=true;
with adoquery1 do
begin
close;
sql.Clear;
SQL.add('select * from password ');//+edit1.Text+'=序号 and '+edit2.Text+'=序号');
Sql.add('where 姓名=:p1 ');
Sql.add(' and 密码=:p2 ');
Parameters.ParamByName('p1').Value:=edit1.Text;
Parameters.ParamByName('p2').Value:=edit2.Text;
prepared;
open;if adoquery1.RecordCount=1 then
ModalResult:=MrOK
else
begin
// ModalResult:=MrCancel ;//好像这个不能要,否则即使密码错误,他还使能进入到主窗体。
showmessage('对不起!用户名或者密码错误');
edit1.SetFocus;
end;
end;
end;
登陆窗体代码还是你原来的。
var
denglu: Tdenglu;
Function CreateFirst:boolean;
implementation{$R *.dfm}
Function CreateFirst:boolean;
begin
With Tdenglu.Create(Application) do
result:= showmodal = mrOK ;
end;工程代码:{$R *.res}begin
Application.Initialize;
if not(CreateFirst) then ///这里我用if CreateFirst then不行,所以加了个not就行了,为何?
begin
Application.CreateForm(TForm1, Form1);
Application.Run;
end
else
Application.Terminate;
end.
登陆取消按钮代码
Application.Terminate;
现在一切ok了