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移动应用程序对话框的更多相关文章

  1. Delphi for iOS开发指南(3):创建一个FireMonkey iOS应用程序

    http://cache.baiducontent.com/c?m=9d78d513d9d431a94f9d92697d60c015134381132ba1d0020fa48449e3732b4b50 ...

  2. VS 2008 创建MFC程序对话框的步骤

    用过不少编程语言,可是刚开始学的时候最容易忘记一些简单的流程或者生疏了.那么这里就说说VS 2008 创建MFC程序对话框的步骤.我主要是android开发方面的.平时使用jni调用不少c++代码.所 ...

  3. xe5 firemonkey关闭应用程序

    在FMX中,由Activity替代了Form的概念,虽然TForm类仍然存在,但MainForm通过关闭函数无法结束程序,使用Application.Terminate均无效,调整为: uses   ...

  4. 小程序 模态对话框自定义组件(modal)

    1. 概述 1.1 说明 小程序中使用wx.showModal(Object object)打开一个模态对话框,但是目前小程序所提供的modal中的内容显示比较死板,不能够完全满足工作中所遇到的功能信 ...

  5. Delphi for iOS开发指南(8):在iOS应用程序中使用Tab组件来显示分页

    Delphi for iOS开发指南(8):在iOS应用程序中使用Tab组件来显示分页 在FireMonkey iOS应用程序中的Tab Tab由FMX.TabControl.TTabControl定 ...

  6. Delphi for iOS开发指南(6):在iOS应用程序中使用ComboBox组件来从列表中选择某一项

    http://blog.csdn.net/delphiteacher/article/details/8924110 Delphi for iOS开发指南(6):在iOS应用程序中使用ComboBox ...

  7. Delphi for iOS开发指南(5):在iOS应用程序中使用Calendar组件来选择日期

    http://blog.csdn.net/delphiteacher/article/details/8923519 在FireMonkey iOS应用程序中的Calendar FireMonkey使 ...

  8. [转]C# 应用程序安装部署步骤,安装前操作,先退出程序后卸载。

    1. 点击[文件]-[新建]-[项目]-其他项目类型-安装和部署,选择安装项目,在下面的名称栏填写SetupTest(或者选择安装向导,一直点击[下一步])2. 安装项目----六个子项依次为:文件系 ...

  9. GTK+系统中的对话框(GTK+dialogs)

    GTK+系统中的对话框(GTK+dialogs) GTK+系统中的对话框(GTK+ dialogs) 在接下来的章节中我们将着重介绍GTK+系统中的对话框. 对话框窗口是众多GUI应用程序中不可或缺的 ...

随机推荐

  1. [Oracle]配置path使oracle备份/导入数据命令exp/imp起作用

    将E:\Oracle11g\app\Administrator\product\11.2.0\dbhome_1\bin;路径添加如path

  2. socket编写简单回显server

    socket在公司代码中应用比较广,比如接口调用的IPCRPC机制,经常看到这样的代码,但是一直也没有动手写过. 在某个比较大的进程中创建一个子进程,由于父子进程复制会浪费内存,可以将创建进程的命令通 ...

  3. 结构类模式(四):装饰(Decorator)

    定义 动态地将责任附加到对象上.若要扩展功能,装饰者提供了比继承更有弹性的替代方案. 它是通过创建一个包装对象,也就是装饰来包裹真实的对象. 特点 装饰对象和真实对象有相同的接口.这样客户端对象就能以 ...

  4. GET与POST提交

    get是从服务器上获取数据,post是向服务器传送数据. get 是把参数数据队列加到提交表单的ACTION属性所指的URL中,值和表单内各个字段一一对应,[在URL中可以看到].post是通过HTT ...

  5. non-manifold Mesh(非流形网格)

    三角网格曲面中,大多的算法基于流形网格manifold mesh,其定义如下: 1)Each edge is incident to only one or two faces: 一条网格边为一个或两 ...

  6. jQuery each,避免使用js for循环

    What is the difference between $.each(selector) and $(selector).each(): http://stackoverflow.com/que ...

  7. Flex 舞台背景渐变

    <?xml version="1.0" encoding="utf-8"?><s:Application xmlns:fx="htt ...

  8. php网站的定时事件

    提示信息: 1.crontab    (脚本定时.) 2. php    XXX.php(注:xxx.php页面是具体要做的事情.)

  9. 学会自己写jQuery插件(一)---基础

    第一步:定义插件 $(function() { $.fn.插件名称 = function(options) { var defaults = { Event : "click", ...

  10. 【转】python代码风格-PEP8

    转载自http://www.douban.com/note/134971609/ Python 的代码风格由 PEP 8 描述.这个文档描述了 Python 编程风格的方方面面.在遵守这个文档的条件下 ...