作者:碎碎念囧雷 | 来源:互联网 | 2023-09-16 18:11
大家好:
我想实现登陆后再出现主画面的功能,即输入用户名和密码后再出现带主菜单的主画面,但不知如何实现。急用这个功能,望大家指点,最好能给出详细代码,谢谢!
王振亚
2003.09.12
3 个解决方案
在你的DPR文件中写入如下代码:
Application.Initialize;
Application.Title := '客户端管理系统';
{读出DB.INI文件,配置数据模块的连接字符串}
Application.CreateForm(TDataModule1, DataModule1);
DataModule1.ADOConnection1.Connected:= false;
try
DataModule1.ADOConnection1.ConnectionString:= GetConnectionString;
DataModule1.ADOConnection1.Connected:= true;
except
on e:exception do
begin
MessageBox(Application.Handle,Pchar('数据库初始化设置错误,请与系统管理员联系!' + char(13) + string(e.Message)),'错误',MB_OK OR MB_ICONSTOP);
Exit;
end;
end;
{打开登录窗口,根据用户权限进行登录}
try
UserLoginForm:= TUserLoginForm.Create(Application);
if UserLoginForm.ShowModal=100 then
Application.CreateForm(TMainform, Mainform)
else
Application.Terminate;
finally
UserLoginForm.Free;
UserLoginForm:= nil;
end;
{运行应用程序}
Application.Run;
drate(小虫)先生:
你好,我新建了一个应用程序,并用你提供的代码全部覆盖了该程序的.dpr文件,编译器提示了很多错误,第一条错误就是:“undeclared identifier tdatamodule1”。我是个delphi新手,能在网上遇到你这样一位高人,真是幸运。望能得到你更详细的指点,你能不能站在一个新手的立场给出更加详细的代码。谢谢!
王振亚
2003.09.12
program gwglclient;
uses
Forms,
Controls,
mainform in 'mainform.pas' {Formtemp},
datamodul2 in 'datamodul2.pas' {DM2: TDataModule},
mima in 'mima.pas' {Form2},
client1 in 'client1.pas' {Form1},
fsong in 'fsong.pas' {Form4},
gz in 'gz.pas' {Form12},
luokuan in 'luokuan.pas' {Form13},
inputfile in 'inputfile.pas' {Form10},
rereg in 'rereg.pas' {Form5},
pjy in 'pjy.pas' {Form6},
send in 'send.pas' {gwjs},
preview in 'preview.pas' {Form11},
datamodul1 in 'datamodul1.pas' {DM1: TDataModule},
reinputpass in 'reinputpass.pas' {reinputpassform};
{$R *.RES}
begin
Application.Initialize;
Application.CreateForm(TDM1, DM1);
Application.CreateForm(TDM2, DM2);
Application.CreateForm(TForm1, Form1);
Application.CreateForm(TForm4, Form4);
Form2:=TForm2.Create(Application);
If Form2.ShowModal=mrOk then
begin
application.Title:='公文管理系统-客户端';
Application.Run;
end
Else
begin
dm1.Free;
dm2.Free;
Form1.Free;
Application.Terminate;
end;
end.