Σάββατο 25 Ιανουαρίου 2014

Modal form in android

If you want to use modal form in an android XE5 application you need to implement it :)...


You open the form as modal like this:

Frm.ShowModal(
    procedure(ModalResult: TModalResult)
    begin
      if ModalResult = mrOK then Begin
        //Do something
      End;
      Frm.Close;
    end
  );

If you want to return result you must send a procedure as parameter.
In the modal form add:  
type CallForResult = Procedure (ResultValue : Variant) Of Object;

procedure OpenFormForResult(Res:CallForResult);
Begin
Frm.ShowModal(
    procedure(ModalResult: TModalResult)
    begin
      if ModalResult = mrOK then
CallForResult('return value');
      Frm.Close;
    end
  );

 End;

In the calling form you must have a CallForResult procedure eg.:

Procedure FetchResult(ResultValue:Variant);

....

Procedure TForm1.FetchResult(ResultValue:Variant);
Begin
      ShowMessage('Return result:'+VarToStr(ResultValue));
End;

 

Δεν υπάρχουν σχόλια:

Δημοσίευση σχολίου