我做了一个登陆窗体和一个主界面窗体,希望先出现登陆窗体,输入密码通过验证后登陆窗体消失,主窗体显示,主窗体的BORDERSTYLE为BSSINGLE,两个窗体VISIBLE为FALSE;在主窗体ONACTIVE的时候登陆窗体ShowModal,验证密码后登陆窗体CLOSE,主窗体显示出来,但同样的我只把主窗体的BORDERSTYLE改为BSSIZEABLE后运行就会两个窗体同时出现,我想在验证时只出现登陆窗体而且主窗体BORDERSTYLE又为BSSIZEABLE怎么办?
谁给个详细的解决方法,或例程。
谁给个详细的解决方法,或例程。
解决方案 »
- 登录窗口为什么显示不了
- 可以使用任何字体的gvim for win32
- 关于使用waveOutWrite播放音频的问题
- 找工作_开价_散分!
- 答案:有一个Dephi写的软件,我想把它界面、菜单上的中文改为英文,有什么工具可以修改?
- 如何找到指定的字符在某一字符串中出现的每一次的位置?
- 为什么我在用NMUDP发送数据时当接收端程序没有启动的时候总是提示Stream Write Error,是什么原因,怎么才能让这个错误提示不出现
- 请高手帮忙,一定给分。。。
- 关于处理文字的一个问题
- 用nmsmtp这样发送邮件,为什么收到的发件人是许多人的邮件地址?
- 如何将10进制数转化为16进制数呢
- 这是什么问题??
=====================
unit UserCtl;interfaceUses Classes, Forms ,Windows ,SysUtils ,ADODB, IniFiles;Type TAppUser = Class(Tobject)
Private
UserID :String;
Public
UserName :String;
UserType :Integer;
Connection :TAdoConnection;
constructor Create();
destructor Destroy();override;
Function Login():Boolean;
Procedure SetPower();
Procedure RelasePower();
end;Var AppUser:TAppUser;implementation
uses Logon ,Main;Const IniName ='AppInfo.ini';
U_SQL ='Select * From Operator Where ID=:UID and Pwd=:UPwd';
ErrTitle = '´íÎóÌáʾ';{ UserInfo }constructor TAppUser.Create;
Var Ini:TIniFile;
begin
inherited;
Ini :=TIniFile.Create(ExtractFilePath(Application.ExeName)+IniName);
try
UserID:=Ini.ReadString('Init','DefaultUser','');
finally
Ini.Free;
end;
end;destructor TAppUser.Destroy;
begin
inherited;end;
//============================Óû§µÇ¼ģ¿é==============================
function TAppUser.Login(): Boolean;
Var Q_User:TAdoQuery;
Password :String;
LogTimes :Integer;
Loged :Boolean;
Ini:TIniFile;
begin
LogTimes :=0;
Loged :=False;
LoginForm :=TLoginForm.Create(Application);
LoginForm.Again :=False;
Q_User :=TAdoQuery.Create(nil);
Try
Q_User.Connection :=Connection;
Q_User.SQL.Text :=U_SQL;
LoginForm.Caption :='ÇëµÇ¼ϵͳ';
Repeat
if LogTimes=3 then Break;
LoginForm.IdEdit.Text := UserID;
LoginForm.PwdEdit.Clear;
if LoginForm.ShowModal =2 then break;
LoginForm.Again :=True;
Inc(LogTimes);
UserID:=LoginForm.IdEdit.Text; //改
Password :=LoginForm.PwdEdit.Text; //改
Q_User.Close;
Q_User.Parameters.ParamByName('UID').Value :=UserID;
Q_User.Parameters.ParamByName('UPwd').Value :=Password;
Q_User.Open;
if Q_User.RecordCount<>0 then
Begin
UserName :=Q_User.FieldByName('Name').AsString;
UserType :=Q_User.FieldByName('Type').AsInteger;
Loged :=True;
Ini :=TIniFile.Create(ExtractFilePath(Application.ExeName)+IniName);
try
Ini.WriteString('Init','DefaultUser',UserID);
finally
Ini.Free;
end;
end
Else Application.MessageBox('Óû§Ãû»òÃÜÂë´íÎó',ErrTitle,MB_OK OR MB_ICONERROR);
Until Loged;
Result :=Loged;
finally
LoginForm.Free;
Q_User.Free;
end;
end;procedure TAppUser.SetPower();
begin
With MainForm do
Begin end;
end;procedure TAppUser.RelasePower();
begin
//
end;
initialization
AppUser:=TAppUser.Create();finalization
AppUser.Free;end.//============用法=================
procedure TDM.DMCreate(Sender: TObject);
begin
MainConnect.ConnectionString :='Provider=Microsoft.Jet.OLEDB.4.0;Data Source=.\DB\AmWayDB.mdb;Persist Security Info=False';
Try
MainConnect.Connected :=True;
Except
Messagebox(0,'Á¬½ÓϵͳÊý¾Ý¿â³ö´í£¬Çë¼ì²é£¡','´íÎó',MB_OK OR MB_ICONERROR);
Application.Terminate;
end;
AppUser.Connection :=MainConnect;
if not AppUser.Login then Application.Terminate;
end;
如:
Function loginover : boolean;
begin
application.CreateForm(TloginForm,loginform);
loginform.showmodal;
......
result:=登陆成功.
loginform.free;
end;在.dpr文件中写入以下代码.
begin
Application.Initialize;
Application.CreateForm(TMainForm, MainForm); IF not Loginover then MainForm.Free;//MainForm是主程序.
Application.Run;end.
这是工程单元文件:
program ycerp;uses
Forms,
Unit2 in 'Unit2.pas' {LoginForm},
MainForm in 'MainForm.pas' {Main_form},
AddGroup in 'AddGroup.pas' {Add_group};{$R *.res}begin
Application.Initialize;
LoginForm := TLoginForm.Create(Application);
LoginForm.ShowModal;
LoginForm.Free;
Application.CreateForm(TMain_form, Main_form);
Application.Run;
end.这样的话,只有在你在LoginForm里判断它输入不满足条件以后,你就让程序结束(Application.Terminate),满足条件好就关闭窗口就行了(LoginForm.close),那样
主窗口就显示出来了,Loginform一定从Auto Create里去掉。
还有什么不明白,就用QQ联系我就行了,QQ:106873731