定义一个全局变量blnLogin(Boolean),未登陆的情况下为false,就出现登陆窗口,登陆成功后将blnLogin改为true,然后执行相应的过程就可以了

解决方案 »

  1.   

    if login then
    begin
      if sender is button1 then
        ..
      else if sender is buuto2 then
        ..
      ...
    end;
      

  2.   

    to:tommychim:
    能说一下具体的代码吗?
    tosunyanbin:
    我按照你的说法做却提示[Error] Unit1.pas(46): Operator not applicable to this operand type.
      

  3.   

    unit PasswordFrm;
    interface
    type
      TForm1 = Class(TForm)
       Edit1:TEdit;
      ......
      ......
      end;function ShowPassordForm(var Password:String):TModalResult;
    {var
      Form1:TForm1;
    }
    删掉上面两句
    implention
    function ShowPassordForm(var Passord:String):TModalResult;
    begin
      with TForm.Create(Application)do
      begin
        try 
          Result := ShowModal;
          if Result = mrOk then
            Password := Edit1.Text;     
        finally
          Free;
        end; 
      end;
    end;  
    end.
    //上面是密码输入单元
    在需要按钮的OnClick事件内调用
    var
      Password:String;
    begin
      if ShowPasswordForm(Password) = mrOk then
      begin
        //验证密码
        //如果正确做你的事情
      end;
    end;  
      

  4.   

    也可以在登窗口定义一个全局变量,当你按下各个按钮时就对这个变量赋值。
    procedure TForm1.Button1Click(Sender: TObject);
    begin
    with TForm.Create(Application)do
      begin
        try 
          MyButton:='ButtonName';
          ShowModal;
        finally
          Free;
        end; 
      end;
    再在登陆窗体上判断这个MyButton是什么就可了end;