ShowModal在FireMonkey移动应用程序对话框
This is the only code that changes between the first and second code snippets:
dlg.ShowModal(procedure(ModalResult: TModalResult)
begin
if ModalResult = mrOK then
// if OK was pressed and an item is selected, pick it
if dlg.ListBox1.ItemIndex >= then
edit1.Text := dlg.ListBox1.Items [dlg.ListBox1.ItemIndex];
dlg.DisposeOf;
end);
第一个代码片段:典型的代码调用的ShowModal
procedure THeaderFooterForm.btnPickClick(Sender: TObject);
var
dlg: TForm1;
begin
dlg := TForm1.Create(nil);
try
// select current value, if avaialble in the list
dlg.ListBox1.ItemIndex := dlg.ListBox1.Items.IndexOf(edit1.Text); if dlg.ShowModal = mrOK then
// if OK was pressed and an item is selected, pick it
if dlg.ListBox1.ItemIndex >= then
edit1.Text := dlg.ListBox1.Items [dlg.ListBox1.ItemIndex];
finally
dlg.Free;
end; end;
伪代码典型的ShowModal代码片段解读
这里是一个描述每个此过程的一部分:
声明局部变量
dlg: TForm1;
创建表格的形式和初始化成员
dlg := TForm1.Create(nil);
dlg.ListBox1.ItemIndex := dlg.ListBox1.Items.IndexOf(edit1.Text);
显示的形式模态
if dlg.ShowModal = mrOK then
检查用户的结果和处理数据
if dlg.ListBox1.ItemIndex >= then
edit1.Text := dlg.ListBox1.Items [dlg.ListBox1.ItemIndex];
释放表单 dlg.Free;
第二个代码片段:作为一个匿名的方式在所有平台上调用的ShowModal
随着移动平台,你应该改变这种代码,悦目,让所有支持的目标平台上工作的ShowModal。
procedure THeaderFooterForm.btnPickClick(Sender: TObject);
var
dlg: TForm1;
begin
dlg := TForm1.Create(nil);
// select current value, if available in the list
dlg.ListBox1.ItemIndex := dlg.ListBox1.Items.IndexOf(edit1.Text); dlg.ShowModal(procedure(ModalResult: TModalResult)
begin
if ModalResult = mrOK then
// if OK was pressed and an item is selected, pick it
if dlg.ListBox1.ItemIndex >= then
edit1.Text := dlg.ListBox1.Items [dlg.ListBox1.ItemIndex];
dlg.DisposeOf;
end); end;
匿名方法的ShowModal代码片段的伪代码解读
这里是一个描述发生了什么(做同样的事情,第一个代码段)在第二个代码片段:
Declare local variables
dlg: TForm1; Create form and initialize member in the form
dlg := TForm1.Create(nil);
dlg.ListBox1.ItemIndex := dlg.ListBox1.Items.IndexOf(edit1.Text); Show the form modal
dlg.ShowModal(procedure(ModalResult: TModalResult) Check the user's result and process the data
if ModalResult = mrOK then
if dlg.ListBox1.ItemIndex >= then
edit1.Text := dlg.ListBox1.Items [dlg.ListBox1.ItemIndex]; Free the form
dlg.DisposeOf;
ShowModal在FireMonkey移动应用程序对话框的更多相关文章
- Delphi for iOS开发指南(3):创建一个FireMonkey iOS应用程序
http://cache.baiducontent.com/c?m=9d78d513d9d431a94f9d92697d60c015134381132ba1d0020fa48449e3732b4b50 ...
- VS 2008 创建MFC程序对话框的步骤
用过不少编程语言,可是刚开始学的时候最容易忘记一些简单的流程或者生疏了.那么这里就说说VS 2008 创建MFC程序对话框的步骤.我主要是android开发方面的.平时使用jni调用不少c++代码.所 ...
- xe5 firemonkey关闭应用程序
在FMX中,由Activity替代了Form的概念,虽然TForm类仍然存在,但MainForm通过关闭函数无法结束程序,使用Application.Terminate均无效,调整为: uses ...
- 小程序 模态对话框自定义组件(modal)
1. 概述 1.1 说明 小程序中使用wx.showModal(Object object)打开一个模态对话框,但是目前小程序所提供的modal中的内容显示比较死板,不能够完全满足工作中所遇到的功能信 ...
- Delphi for iOS开发指南(8):在iOS应用程序中使用Tab组件来显示分页
Delphi for iOS开发指南(8):在iOS应用程序中使用Tab组件来显示分页 在FireMonkey iOS应用程序中的Tab Tab由FMX.TabControl.TTabControl定 ...
- Delphi for iOS开发指南(6):在iOS应用程序中使用ComboBox组件来从列表中选择某一项
http://blog.csdn.net/delphiteacher/article/details/8924110 Delphi for iOS开发指南(6):在iOS应用程序中使用ComboBox ...
- Delphi for iOS开发指南(5):在iOS应用程序中使用Calendar组件来选择日期
http://blog.csdn.net/delphiteacher/article/details/8923519 在FireMonkey iOS应用程序中的Calendar FireMonkey使 ...
- [转]C# 应用程序安装部署步骤,安装前操作,先退出程序后卸载。
1. 点击[文件]-[新建]-[项目]-其他项目类型-安装和部署,选择安装项目,在下面的名称栏填写SetupTest(或者选择安装向导,一直点击[下一步])2. 安装项目----六个子项依次为:文件系 ...
- GTK+系统中的对话框(GTK+dialogs)
GTK+系统中的对话框(GTK+dialogs) GTK+系统中的对话框(GTK+ dialogs) 在接下来的章节中我们将着重介绍GTK+系统中的对话框. 对话框窗口是众多GUI应用程序中不可或缺的 ...
随机推荐
- 学习总结(annotation)
自定义MyAnnotationTest package com.zhanghaobo.annotation; import java.lang.annotation.ElementType; impo ...
- Minus-C 一个最小化的C语言规范
资深C++程序员都不会对C++编程规范太陌生,C++实在太复杂,以至于所有项目都需要裁剪一个子集共项目组内使用.经过在家休息这一小段时间,我发现其实C语言更需要一个相同的规范,这就是本文的目标,最大可 ...
- 转载:Flash AS3.0 加载外部资源(图片,MP3,SWF)的两种方式
Flash AS3.0 加载外部资源(图片,MP3,SWF)的两种方式 出自:http://www.cnblogs.com/top5/archive/2012/08/04/2623464.html 关 ...
- php网站的定时事件
提示信息: 1.crontab (脚本定时.) 2. php XXX.php(注:xxx.php页面是具体要做的事情.)
- java中导入常量
import关键字除了导入包之外,还可以导入静态成员,这时JDK5.0以上版本提供的新功能.导入静态成员可以是程序员编程更为方便. 使用import导入静态成员的语法为: import static ...
- TextView 实现复制文本功能
Android api 11 以后可以直接设置 android:textIsSelectable="true" <TextView android:layout_width= ...
- Chrome的JS调试工具
你是怎么调试 JavaScript 程序的?最原始的方法是用 alert() 在页面上打印内容,稍微改进一点的方法是用 console.log() 在 JavaScript 控制台上输出内容.嗯~,用 ...
- 单步运行linux kernel ?
如果能给linux kernel打log,如果能单步运行,如果能像普通应用程序那样,step by step的查看程序跑哪里了.. 该多好?这是一个梦想,但从未实现过:因为那是kernel,不是应用程 ...
- SQL Server2005中使用XML-数据类型、查询与修改
SQL 2005引进了XML数据类型,可以直接将XML当作字符串直接存入该列. 这样可以不需要对它进行XML解析. USE AdventureWorks -- 创建一个送货排程表 CREATE TAB ...
- MySQL中MySQL X.X Command Line Client一闪而过的问题
问题介绍:我安装完MySQL(我安装的是5.5)后,使用MySQL 5.5 Command Line Client,每次点击,总是一闪而过.解决方法如下: 首先进入cmd 切入MySQL的安 ...