在delphi firemonkey移动应用程序关闭模态对话框(安卓) [英] Closing modal dialog in delphi firemonkey mobile application (Android)
问题描述
我遇到的dandiest时间试图找出为什么我的模式窗体不会关闭! 用Delphi XE-5和FireMonkey手机软件(安卓),我跟着的信息的ShowModal对话框在FireMonkey移动应用
I am having the dandiest time trying to figure out why my modal form will not close! Using Delphi XE-5 and FireMonkey Mobile App (Android), i followed the the info "ShowModal Dialogs in FireMonkey Mobile Apps"
用于演示目的,我创建了一个新的Firemonkey移动Delphi应用程序,并增加了一个二级firemonkey移动形式。从主要形式,我用的是code从文章:
for demo purposes, i created a new Firemonkey Mobile delphi application and added a secondary firemonkey mobile form. From the main form, i use the code from the article:
procedure TForm1.Button1Click(Sender: TObject);
var
Form2: TForm2;
begin
Form2 := TForm2.Create(nil);
Form2.ShowModal(procedure(ModalResult: TModalResult)
begin
if ModalResult = mrOK then
begin
//
end;
Form2.DisposeOf;
end);
end;
在二级形式,我分配确定和取消按钮,分别modalresult属性设置为mrCancel和mrOK。然而,显示模态对话框时,既没有按钮使对话框关闭。我甚至尝试添加的onClick事件和分配modalresult由code。为什么惯于形式接近?我想我需要保证我做全部的寄托权以及可能的我的手机(设备)?
On the secondary form, i assign the "Ok" and "Cancel" buttons modalresult property to "mrCancel" and "mrOK", respectively. However, when the modal dialog is shown, neither button makes the dialog close. I even tried adding onClick events and assigning the modalresult by code. Why wont the form close? I guess I need assurance that I did everthing right and possible its my PHONE (device)?
推荐答案
为了关闭自己的模态对话框,使用这种模式:
In order to close your modal dialog, use this pattern:
procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := TCloseAction.caFree;
end;
和删除您的通话 Form2.DisposeOf;
,因为 ModalResult
制定者需要在一个有效的对象进行操作。
and remove your call Form2.DisposeOf;
, since the ModalResult
setter needs to operate on a valid object.
该文档已经在XE7更新,请参见使用FireMonkey模态对话框。
The documentation has been updated in XE7, see Using FireMonkey Modal Dialog Boxes.
参见的ShowModal在Android 了解详情为什么 DisposeOf
是错误的。
See also ShowModal on Android for the details why DisposeOf
is wrong.
这篇关于在delphi firemonkey移动应用程序关闭模态对话框(安卓)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!