数据库程序(100分)

  • 主题发起人 主题发起人 yeshow
  • 开始时间 开始时间
Y

yeshow

Unregistered / Unconfirmed
GUEST, unregistred user!
我现在为一个朋友做一个数据库,有三个窗体,
第一个是登录窗体,
第二个是主程序窗体(MDIForm),
第三个则是数据录入查询窗体(MDIChild);
现在问题是MDIForm属性不能给第二个;
我要实现的功能是程序运行后出现登录窗体,
验证正确后打开主程序窗体,同时登录窗体隐藏,相应的用户给予相应的操作权限;
再通过主程序的下拉菜单打开相应的子窗体;
但是在主程序窗体里打开(不是新建)已建立的子窗体时,有这样的出错提示:
“cannot create form,No MDIForms a currently active."
我急急!!!
 
登录窗体用完之后,free掉看看
 
这样可不可以。
项目文件中写
Application.Initialize;
LogoForm:=TLogoForm.Create(application);
LogoForm.Show;
LogoForm.Update;
while LogoForm.Timer1.Enabled do
application.ProcessMessages;
Application.CreateForm(TForm1, Form1);
LogoForm.Hide;
LogoForm.Free;
Application.Run;
end;
在SplashForm中加一个Timer控件,设时间
然后
procedure TLogoForm.Timer1Timer(Sender: TObject);
begin
Timer1.Enabled:=false;
end;
 
第一个窗体不能在程序开始时创建,可修改DPR文件或使用PROJECT中的OPTION更改
 
在项目管理里让子
窗体不在程序开始时创建
To create a new child window at runtime:

1.Locate the point in your code where you want to create a child window.

This will usually be an event handler for a menu item. If necessary,
generate an empty event handler for the desired menu-item click.

2.Call the Create method of the child-window form you want an instance of,
and pass the frame window as the Owner parameter to the Create method.

In the following example, the frame form's handler calls the Create method
for the child form type (TEditForm). The child form's handler just calls
the frame form's handler.

procedure TFrameForm.New1Click(Sender: TObject);
begin
TEditForm.Create(Self); // create the new child window
end;
procedure TEditForm.New1Click(Sender: TObject);
begin
FrameForm.New1Click(Sender); // call the frame form's handler
end;
ok 了
 
大花鸡:
我是你那样做的,你那样做是可以成功创建各个窗体,
但是在登录窗体出现后,你不登录而是关闭登录窗体,
这时会出现问题,不知你试过没有?
 
在FlashForm中的OnCLose中写application.Terminate;或在Close按钮中这么写,没事呀!
 
可以把登录窗体放在主窗体的OnCreate事件中,如果登录失败则跳过主窗体其他的创建过程,
设一个全局变量即可。
 
那样不行!你试过以后告诉我吧!先谢了~~~~~~~
 
var
mr:integer;

Application.Initialize;
LogoForm:=TLogoForm.Create(application);
mr:=LogoForm.ShowModal;
LogoForm.Free;
if mr<>mrOk then //如果你的LogoForm的确定按钮返回mrOk的话,就是在ok按钮那里要设置ModalResult:=mrOk;
exit;
Application.CreateForm(TForm1, Form1);
Application.Run
 
TO PiPi:
我程序是这样写的:
项目文件中写
Application.Initialize;
LoginForm:=TLogoForm.Create(application);
LoginForm.Show;
LoginForm.Update;
while LoginForm.Timer1.Enabled do
application.ProcessMessages;
LoginForm.Hide;
LoginForm.Free;
Application.CreateForm(TForm1, Form1);
Application.Run;
end;
在loginForm中加一个Timer控件,设时间

这样可以创建各个窗体,登录窗体出现了,密码验证完全正确时顺利地进入到主程序(MDI窗体),
然后打开已建立的子窗体;
但是在登录窗体出现时,我不输入用户名和密码,我退出程序,这时就有问题了!
在loginform窗体的onclose事件和cancel按钮的事件里加入这样的一句也不行:
application.Terminate;
是不是因为项目文件里创建了form1,而没有用到的原因?
是不是要先显示,然后关闭?
 
干嘛要用timer啊,那个timer时间一到……就出问题了,我的showmodal的不行吗
 
不要用TTimer,我常用zzWind的办法,把LoginForm写在ONCREATE里,
再把LoginForm和数据录入查询窗体设为手动创建就行了
 
我在朋友的帮助下做好了,不过还是要谢谢各位!问题就像PiPi所说的一样,我那样写,当
直接关闭的时候,FormLogin窗体在等时间……我的代码是这样实现的:
procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
timer1.Enabled:=false;
application.Terminate;
end;
 
呵呵,写好了最好。
 
YeShow:你是如何留言的?
 
多人接受答案了。
 
后退
顶部