请问一下大家都是怎么样设计登录窗口的.机制是怎么样.
一个MDI程序.
大家是把MDi窗口做为主窗口呢,还是把Login窗口做为主窗口呢.
我是把Login窗口做为主窗口,把确认后再创建MDI窗口,关显示.
最后隐藏login窗口,但总觉的不太好.大家有没有好的方法.

解决方案 »

  1.   

    以MDI为主窗口,登录界面在create form 时创建就可以了
      

  2.   

    以MDI为主窗口,给你一段程序,自己领悟吧program SMSCXMON;uses
      Forms,  Sysutils,
      frm_SMSset in 'frm_SMSset.pas' {frmSMSCXset},
      pfStrings in '..\公共单元\pfStrings.pas',
      DDPubfun in '..\公共单元\DDPubfun.pas',
      frm_cxSQL in 'frm_cxSQL.pas' {frmCXSQL},
      MainDataModule in '..\公共窗体单元\MainDataModule.pas' {Dm_Main: TDataModule},
      UserLogin in '..\公共窗体单元\UserLogin.pas' {frm_SysLogin},
      DataBaseSet in '..\组件单元\DataBaseSet.pas',
      DataServerSet in '..\公共窗体单元\DataServerSet.pas' {frm_DataServerSet},
      ChangeUserPass in '..\公共窗体单元\ChangeUserPass.pas' {frm_ChangeUserPass},
      ConnMsg in '..\公共窗体单元\ConnMsg.pas' {frm_ConnMsg},
      PubDBFunc in '..\公共单元\PubDBFunc.pas',
      pubFunc in '..\公共单元\pubFunc.pas',
      PubVardef in '..\公共单元\PubVardef.pas',
      pubVarFun in '..\公共单元\pubVarFun.pas',
      SQLDesiger in '..\SQL工具\SQLDesiger.pas' {frm_SQLDesiger},
      frm_SMSMonitor in 'frm_SMSMonitor.pas' {frmSMSMonitor},
      GSMControl3 in 'Pack\GSMControl3.pas',
      xyDebug in 'Pack\xyDebug.pas',
      xyPack in 'Pack\xyPack.pas',
      xyPackThd in 'Pack\xypackthd.pas',
      xyTypeConv in 'Pack\xyTypeConv.pas',
      frm_RYXX in 'frm_RYXX.pas' {frmRYXX},
      xStrGrid in '..\公共窗体单元\xStrGrid.pas',
      frm_DDL in 'frm_DDL.pas' {frmDDLSet},
      frm_RYSel in 'frm_RYSel.pas' {frmRYSel},
      frm_DDLSel in 'frm_DDLSel.pas' {frmDDLSel},
      frm_TJView in '..\统计视图\frm_TJView.pas' {frmTJView},
      TjTabSel in '..\统计视图\TjTabSel.pas' {frm_TjTabSel},
      about in '..\公共窗体单元\about.pas' {frm_about},
      frm_Print in 'frm_Print.pas' {frmPrint},
      frm_DXLOG in 'frm_DXLOG.pas' {frmDXLog},
      frm_CXLog in 'frm_CXLog.pas' {frmCXLog},
      frm_ExpTask in '..\导入导出\frm_ExpTask.pas' {frmExpTask},
      frm_DDLCK in 'frm_DDLCK.pas' {frmDDLCK},
      frm_Search in 'frm_Search.pas' {frm_SearchDBGrid},
      frm_LogView in 'frm_LogView.pas' {frm_log},
      xyNodeb in '..\表达式\xyNodeb.pas',
      frm_DataExpImp in '..\导入导出\frm_DataExpImp.pas' {frmDataExpImp},
      frm_DataExpAdd in '..\导入导出\frm_DataExpAdd.pas' {frmDataExpImpAdd},
      frm_DataLink in '..\导入导出\frm_DataLink.pas' {frmDataLink};{$R *.RES}begin
      Application.Initialize;
      Application.Title := '短信查询监控';
      Apppath := IncludeTrailingBackslash(ExtractFileDir(ParamStr(0))) ;  helpPath := UpLevelDir(AppPath) + 'help\';
      Application.CreateForm(TDm_Main, Dm_Main);  pubDBConfig.Connected := false;  if loginOK then
      begin
        if issysright(DDLGL,Pub_UserInfo.SysRight) then
        begin
          Application.CreateForm(TfrmSMSMonitor, frmSMSMonitor);
          Application.Run;
        end else
        begin
          showmsg(0,'你没有调度管理的权限.');
        end;
      end;
    end.[loginok函数]function LoginOK: boolean;
    begin
      Try
        frm_ConnMsg:= Tfrm_ConnMsg.Create(nil);
        if assigned(frm_SysLogin) then
        begin
          frm_SysLogin.free;
          frm_SysLogin := nil;
        end;
        frm_SysLogin := Tfrm_SysLogin.Create(nil);
        frm_SysLogin.DataBase := dm_Main.DataBase1;
        if frm_SysLogin.ShowModal = mrOK then
          result := true
        else result := false;
        PubDatabaseName := 'RepData';
      finally
        FreeAndNil(frm_ConnMsg) ;
        frm_SysLogin.free;
        frm_SysLogin := nil;
      end;
    end;frm_SysLogin 是你用来验证用户名与口令窗体
      

  3.   

    我会把登录窗口写在.DPR文件中{读出DB.INI文件,配置数据模块的连接字符串}
      Application.CreateForm(TDataModule1, DataModule1);
      Application.CreateForm(TImportQueryGdsform, ImportQueryGdsform);
      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;
      

  4.   

    动态创建一窗口,用完后,就FREE掉就行了,这个好象没什么好讨论的吧
      

  5.   

    动态创建Login窗体,登录后释放之
      

  6.   

    try
       login := TLogin.create(nil);
       if Login.showmodal= mrok then
         ApplicationRunfinaly
       login.free;
    end;
      

  7.   

    各位,还是有点不太明白的地方.
    MDI程序是不是也可以不用MDI窗口做主窗口的.就是在project-option中的设置