How to confirm delete of a record in Delphi FMX Android

  

Typically in a Delphi VCL application which uses a TDataset descendent as data storage (eg TClientDataset), in the Dataset1BeforeDelete handler we do something like this:

procedure TClientModule1.MyCDSBeforeDelete(DataSet: TDataSet);
begin
if MessageDlg(‘Delete?’, mtCOnfirmation, [mbyes, mbNo], 0) <> mrYes then
SysUtils.Abort
end;

Now in a FMX application designed to run on Android, this becomes:

procedure TClientModule1.MyCDSBeforeDelete(DataSet: TDataSet);
MessageDlg(‘Delete?’
,
TMsgDlgType.mtWarning, [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbNo], 0,
procedure(const AResult: TModalResult)
begin
if AResult <> mrYes then
Abort;
end
);
end;

Except, that’s not going to work! The messagedlg is going to hold the user’s attention, but the event handler code is going to continue and allow the record to be deleted anyway.

What’s the solution?

Comments are closed.