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. jQuery 的选择器

    本文来自网上转帖 1. 基础选择器 Basics 名称 说明 举例 #id 根据元素Id选择 $("divId") 选择ID为divId的元素 element 根据元素的名称选择, ...

  2. android 动画属性(一)之Animation

    Animation 在android 程序当中很多时候要用到动画效果,而动画效果主要是Animation来实现的,API给出的解释: 其中包含4种动画效果 AlphaAnimation 渐变透明度 R ...

  3. Linux 基本权限(一)

    1. 权限概念 root@hang:/home# ll 总用量 20#文件权限 链接数量 文件所有者 所属用户组 容量大小B 创建(修改)时间 文件名 drwxr-xr-x root root 11月 ...

  4. Java中移位操作运算符的理解

    java中的移位运算符有三种: 1. <<: 左移 2. >>: 右移 3. >>>: 无符号右移 使用方法:左移就是将左边的操作数在内存中的二进制数据左移指 ...

  5. jQuery日历和日期选取插件

    参考网站:http://developer.51cto.com/art/201103/248670.htm http://www.open-open.com/ajax/3_Calendar.htm 推 ...

  6. Flex利用titleIcon属性给Panel容器标题部添加一个ICON图标

    Flex利用titleIcon属性,给Panel容器标题部添加一个ICON图标. 让我们先来看一下Demo(可以右键View Source或点击这里察看源代码): 下面是完整代码(或点击这里察看): ...

  7. C++在堆上申请和释放内存 - new & delete

    // 动态申请内存, 指向一个未初始化的整型 int *pi = new int; // pi指向一个整型值,初始化为0 int *pi = new int(); // value of i is 1 ...

  8. 由linux内核某个片段(container_of)引发的对于C语言的深入理解

    /usr/src/linux-source-3.8.0/drivers/gpu/drm/radeon 这个文件夹以下 去找到这个文件 mkregtable.c  打开,就能够看到了. #define ...

  9. svn cleanup failed–previous operation has not finished 解决方法

    今天svn遇到一个头疼的问题,最开始更新的时候失败了,因为有文件被锁住了.按照以往的操作,我对父目录进行clean up操作,但是clean up 操作也失败了! svn cleanup failed ...

  10. vi 命令 使用方法

    一.Unix编辑器概述       编辑器是使用计算机的重要工具之中的一个,在各种操作系统中,编辑器都是不可缺少的部件.Unix及其类似的ix 操作系统系列中,为方便各种用户在各个不同的环境中使用,提 ...