Delphi 模式窗体返回值ModalResult的使用方法及注意事项
2015-04-03 23:22
603 查看
1、基础知识简介:
ModalResult是指一个模式窗体(form.showmodal)的返回值,一般用于相应窗体上按钮的ModalResult属性;
显示完窗体(关闭)后,会返回此属性预设的值做为返回值。
2、该属性可以使用的参数(默认值是mrNone):该属性可以设置为mrOk 、mrCancel...等等
mrNone 0 None. Used as a default value before the user exits.
mrOk 1 The user exited with OK button.
mrCancel 2 The user exited with the CANCEL button.
mrYes 3 The user exited with the YES button.
mrNo 4 The user exited with the NO button.
mrAbort 5 The user exited with the ABORT button.
mrRetry 6 The user exited with the RETRY button.
mrIgnore 7 The user exited with the IGNORE button.
mrAll 8 The user exited with the ALL button.
mrNoToAll 9 The user exited with the NO TO ALL button.
mrYesToAll 10 The user exited with the YES TO ALL button.
3、使用注意事项:
1、包含ModalResult属性的按钮执行完毕之后,该按钮所在的窗体会自动关闭,不用在OnClick事件中添加诸如Close语句。
2、同时将按钮的ModalResult属性值赋值给窗体的ModalResult属性(注意:任何窗体都有这个属性!)
3、还有就是窗体的ModalResult属性又会自动传递给showmodal方法,作为该方法的返回值。
4、例如:
如果设置form2窗体的一个按钮的ModalResult为mrYes的话,点击此按钮关闭此窗体的时候,会返回mrYes,从而显示OK
1>. 在form1中可以调用:
if Form2.ShowModal = mrok then
ShowMessage('OK');
2> .在form2的按钮btn1中
procedure TForm2.btn1Click(Sender: TObject);
begin
self.ModalResult := mrok;
end;
ModalResult是指一个模式窗体(form.showmodal)的返回值,一般用于相应窗体上按钮的ModalResult属性;
显示完窗体(关闭)后,会返回此属性预设的值做为返回值。
2、该属性可以使用的参数(默认值是mrNone):该属性可以设置为mrOk 、mrCancel...等等
mrNone 0 None. Used as a default value before the user exits.
mrOk 1 The user exited with OK button.
mrCancel 2 The user exited with the CANCEL button.
mrYes 3 The user exited with the YES button.
mrNo 4 The user exited with the NO button.
mrAbort 5 The user exited with the ABORT button.
mrRetry 6 The user exited with the RETRY button.
mrIgnore 7 The user exited with the IGNORE button.
mrAll 8 The user exited with the ALL button.
mrNoToAll 9 The user exited with the NO TO ALL button.
mrYesToAll 10 The user exited with the YES TO ALL button.
3、使用注意事项:
1、包含ModalResult属性的按钮执行完毕之后,该按钮所在的窗体会自动关闭,不用在OnClick事件中添加诸如Close语句。
2、同时将按钮的ModalResult属性值赋值给窗体的ModalResult属性(注意:任何窗体都有这个属性!)
3、还有就是窗体的ModalResult属性又会自动传递给showmodal方法,作为该方法的返回值。
4、例如:
如果设置form2窗体的一个按钮的ModalResult为mrYes的话,点击此按钮关闭此窗体的时候,会返回mrYes,从而显示OK
1>. 在form1中可以调用:
if Form2.ShowModal = mrok then
ShowMessage('OK');
2> .在form2的按钮btn1中
procedure TForm2.btn1Click(Sender: TObject);
begin
self.ModalResult := mrok;
end;
相关文章推荐
- Delphi 模式窗体返回值ModalResult的使用方法及注意事项
- Delphi 模式窗体返回值ModalResult的使用方法及注意事项
- Delphi 模式窗体返回值ModalResult的使用方法及注意事项(转)
- Delphi 模式窗体返回值ModalResult的使用方法及注意事项(转)
- Delphi 模式窗体返回值ModalResult的使用方法及注意事项
- Delphi 模式窗体返回值ModalResult的使用方法及注意事项
- C++中typename关键字的使用方法和注意事项
- C++中typename关键字的使用方法和注意事项
- C#使用ExecuteReader返回DataReader既有查询结果集又有输出参数和返回值的使用注意事项
- cvFloodFill的使用方法和注意事项。
- cygwin跨平台移植 gcc+vc联合使用的方法和注意事项
- jdom中使用setAttribute(Attribute attribute)方法设置属性的注意事项
- C++中typename关键字的使用方法和注意事项
- C++ typename 关键字的使用方法和注意事项
- delphi的tclientdataset的中文过滤使用注意事项
- ScrolledComposite使用方法及注意事项
- STL中heap的使用方法及注意事项(msdn2003中未提及)
- 使用SPView时的注意事项和问题,及解决方法?
- DELPHI中调用DLL的方法和一些注意事项和技巧
- 分页解决方案 之 分页算法——Pager_SQL的详细使用方法和注意事项