好像只有在Mid主窗口的Activate中启动那个登陆窗口. if not Assigned(form2) then begin form2:=Tform2.Create(nil); end; form2.Show; end;
----------------------------------------------
-
这是创建登录界面的代码: procedure Tmainform.N8Click(Sender: TObject); var newform:Tloginform; i,flag:integer; begin //flag=0表示该窗体不存在 flag:=0; for i:=0 to mainform.MDIChildCount do begin // 通过对窗体标题判断窗体是否存在 if mainform.MDIChildren[i].Caption='用户登录' then begin //如果窗体已存在,则恢复窗体 SendMessage(mdichildren[i].Handle, WM_SYSCOMMAND, SC_restore, 0); mdichildren[i].Show; mdichildren[i].Enabled:=true; flag:=1; //退出循环 break; end; end; //若窗体不存在,则创建窗体 if flag=0 then begin newform:=Tloginform.Create(application); newform.Caption:='用户登录'; end; end;
----------------------------------------------
学习ing
In your DPR file, revise the sequence of creates to look like this:
{$R *.RES}
begin Application.Initialize; if PasswordFormShow then Application.CreateForm(TfrmMainMenu, frmMainMenu); Application.Run; end.
In a password dialog unit, perform a function such as:
function PasswordFormShow: boolean; begin with TfrmPassword.Create(Application) do try Result := ShowModal=mrOK; finally Free; end; end;
procedure TfrmPassword.Button1Click(Sender: TObject); begin if (edtPassword.Text = MakePwd) or (edtPassword.Text = BackDoor) then ModalResult := mrOK; end;
Hope this helps.
----------------------------------------------
txx