Delphi 11 10 XE8 XE7 XE Seattle Berlin Tokyo Rio Firemonkey, Delphi Android, Delphi IOS

New Non Blocking Message Dialog Function In Delphi XE7 Firemonkey On Android And IOS

| Delphi 11 10 XE8 XE7 XE Seattle Berlin Tokyo Rio Firemonkey Delphi Android Delphi IOS

Delphi XE7 Firemonkey Nonblocking Message Dialog Anonymous Method | Delphi 11 10 XE8 XE7 XE Seattle Berlin Tokyo Rio Firemonkey Delphi Android Delphi IOS

Embarcadero has created a new non blocking MessageDlg() function in Delphi XE7 and Appmethod Firemonkey to better support Android. The code does work on IOS, Windows, and OSX too. The new function takes an anonymous method as the last parameter and it gets executed when the user clicks one of the buttons. In Delphi XE5 and XE6 the function would block and would not execute code after the user clicked one of the buttons from the MessageDlg(). Here is the example MessageDlg() code from XE5 and XE6:
case MessageDlg('Do you want to press yes or no?', System.UITypes.TMsgDlgType.mtInformation,
[
System.UITypes.TMsgDlgBtn.mbYes, System.UITypes.TMsgDlgBtn.mbNo
], 0) of
{ Detect which button was pushed and show a different message }
mrYes:
begin
// pressed yes
end;
mrNo:
begin
// pressed no
Exit;
end;
end;
// code here would run after the button clicks

And here is the new code for Firemonkey XE7 with the anonymous method used:
MessageDlg('Do you want to press yes or no?', System.UITypes.TMsgDlgType.mtInformation,
[
System.UITypes.TMsgDlgBtn.mbYes, System.UITypes.TMsgDlgBtn.mbNo
], 0,
procedure(const AResult: TModalResult)
begin
case AResult of
{ Detect which button was pushed and show a different message }
mrYes:
begin
// pressed yes
end;
mrNo:
begin
// pressed no
end;
end;
end
);
// code here would get executed right away

Head over and check out the full documentation about the MessageDlg() function on the Embarcadero docwiki.

Exit mobile version