MessageDlg与Delphi FireMonkey中的自定义按钮标题 [英] MessageDlg with custom button captions in Delphi FireMonkey
问题描述
使用VCL可以使用 CreateMessageDialog
生成带有自定义按钮的消息对话框字幕。
With VCL you can use CreateMessageDialog
to generate a message dialog with custom button captions.
使用FMX CreateMessageDialog
似乎不再存在(自XE3起)。
With FMX CreateMessageDialog
does not seem to exist anymore (since XE3).
有没有办法使用FireMonkey自定义按钮字幕,而不是从头开始重新生成消息对话框?
Is there a way to customize the button captions with FireMonkey other than rebuilding the message dialog from scratch?
我想要的是调用此处所述的功能:
MessageDlg(
'Really quit application ?', mtWarning,
[ButtonInfo(mbNo, 'Do&n''t save'),
ButtonInfo(mbCancel, '&Cancel'),
ButtonInfo(mbYes,'&Save')],
mbYes
);
推荐答案
您无权访问实际的对话框,就像您在VCL中一样。像DadisX在评论中说的,你只能改变资源字符串的值,但是不能触摸对话框本身。
In short, no. You don't have access to the actual dialog, like you do in VCL. Like DadisX said in comment, you can only change the resource string values, but not touch the dialog itself.
但是,就是说,FMX使用一个平台抽象层处理实际的对话框,你可以调整一下。在每个受支持的平台上,FMX有一个类可实现FMX的 IFMXDialogService
界面提供平台适合的对话框。您可以编写实现 IFMXDialogService
的自己的类,并覆盖其 MessageDialog()
方法(以及其他方式)使用自己的自定义对话框执行任何所需操作。然后,您可以使用 IFMXDialogService 的默认类。 RemovePlatformServicerel =nofollow> TPlatformServices.RemovePlatformService()
并使用 TPlatformServices.AddPlatformService()
。
However, with that said, FMX uses a platform abstraction layer to handle the actual dialog, and that you can tweak a bit. On each supported platform, FMX has a class that implement's FMX's IFMXDialogService
interface to provide platform-appropriate dialogs. You can write your own class that implements IFMXDialogService
and overrides its MessageDialog()
method (amongst others) to do whatever you want with your own custom dialogs. Then you can unregister the default class for IFMXDialogService
using TPlatformServices.RemovePlatformService()
and register your class using TPlatformServices.AddPlatformService()
.
有关详细信息,请参阅Embarcadero的文档:
Refer to Embarcadero's documentation for more details:
这篇关于MessageDlg与Delphi FireMonkey中的自定义按钮标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!