Get access to over 100 FireMonkey cross platform samples for Android, IOS, OSX, Windows, and Linux!

AndroidAppmethodCode SnippetDelphiFiremonkeyIOSOSXWindows

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

Delphi XE7 Firemonkey Nonblocking Message Dialog Anonymous Method

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.



Have Delphi Firemonkey questions? Ask and get answers on StackOverflow.

Related posts
AndroidComponentDelphiFiremonkeyIOSOSXWindows

Bring Native HTML Editing And CSS Flexbox Layouts To Delphi FireMonkey

LinuxWindows

Detect And Ban Web Attackers With An AI Judge In Object Pascal

DelphiFiremonkeyLinuxWindows

Give Local AI Agents Short-Term And Long-Term Memory That Learns While You Chat

DelphiDemoFiremonkeyLinuxOSXWindows

Build Classic Desktop Operating System Themes Apps With Styles For FireMonkey

Sign up for our Newsletter and
stay informed
[mailpoet_form id="1"]

5 Comments

Comments are closed.