TFormA.OnClick(Sender: TObject) begin FromB.ShowModal; end;TFormB.btnOKClick(Sender: TObjcet); begin slef.ModalResult := mrOK; end;TFormB.btnCancelClick(Sender: TObject); begin self.ModalResult := mrCancel; end;将鼠标光标移到mrOK后按住Ctrl键不放,点鼠标左键,之后出现的都是modalresult的值
帮助上的 多看帮助 mrNone 0 None. Used as a default value before the user exits. mrOk idOK The user exited with OK button. mrCancel idCancel The user exited with the CANCEL button. mrAbort idAbort The user exited with the ABORT button. mrRetry idRetry The user exited with the RETRY button. mrIgnore idIgnore The user exited with the IGNORE button. mrYes idYes The user exited with the YES button. mrNo idNo The user exited with the NO button. mrAll mrNo + 1 The user exited with the ALL button.mrNoToAll mrAll + 1 The user exited with the NO TO ALL button. mrYesToAll mrNoToAll + 1 The user exited with the YES TO ALL button.
YES 实际就是指定 Form.ShowModal 方法的返回值
ShowModual的返回值中的一种,ShowModal窗体的窗体ModalResult为非0的时候,窗体就会关闭。其他非零的返回值,我们可以用来做一些判断。比如一个系统,我们点击登陆,用ShowModal的方式显示,通过校验用户名、密码,正确的话我们就将ModalResult赋值为mrOk,我们可以通过判断ShowModal的返回值来判断是否能够登陆。 比如 fm2 := TForm2.Create(Self); if fm2.ShowModal = mrOk then ShowMessage('Login suc!');
窗体按钮都是什么按钮;
modalresult都有多少种情况
begin
FromB.ShowModal;
end;TFormB.btnOKClick(Sender: TObjcet);
begin
slef.ModalResult := mrOK;
end;TFormB.btnCancelClick(Sender: TObject);
begin
self.ModalResult := mrCancel;
end;将鼠标光标移到mrOK后按住Ctrl键不放,点鼠标左键,之后出现的都是modalresult的值
mrNone 0 None. Used as a default value before the user exits.
mrOk idOK The user exited with OK button.
mrCancel idCancel The user exited with the CANCEL button.
mrAbort idAbort The user exited with the ABORT button.
mrRetry idRetry The user exited with the RETRY button.
mrIgnore idIgnore The user exited with the IGNORE button.
mrYes idYes The user exited with the YES button.
mrNo idNo The user exited with the NO button.
mrAll mrNo + 1 The user exited with the ALL button.mrNoToAll mrAll + 1 The user exited with the NO TO ALL button.
mrYesToAll mrNoToAll + 1 The user exited with the YES TO ALL button.
实际就是指定 Form.ShowModal 方法的返回值
比如
fm2 := TForm2.Create(Self);
if fm2.ShowModal = mrOk then
ShowMessage('Login suc!');