【问题标题】:MessageDlg with Custom button text带有自定义按钮文本的 MessageDlg
【发布时间】:2023-01-25 17:27:21
【问题描述】:

根据 Delphi 11.1 中的参数提示,MessageDlg 应该支持在最后一个参数的字符串数组中定义的自定义按钮名称。 例如

我无法让它工作。我声明了一个常量 3 元素字符串数组,但编译器声称没有具有这种格式的 MessageDlg 的重载版本。

任何人都可以告诉我这应该如何工作还是参数帮助中的错误。

【问题讨论】:

标签: delphi


【解决方案1】:

没问题,它工作正常

var
CustomButtonCaptions: array of string;
begin
 SetLength(CustomButtonCaptions , 5 );
 CustomButtonCaptions[0] := 'Button-1';
 CustomButtonCaptions[1] := 'Button-2';
 CustomButtonCaptions[2] := 'Button-3';
 CustomButtonCaptions[3] := 'Button-4';
 CustomButtonCaptions[4] := 'Button-5';

  case MessageDlg('MSG',TMsgDlgType.mtConfirmation,mbYesAllNoAllCancel,0,TMsgDlgBtn.mbClose,CustomButtonCaptions) of
      0:
      begin

      end;
  end;
end;

// Or

MessageDlg('MSG',TMsgDlgType.mtConfirmation,mbYesAllNoAllCancel,0,TMsgDlgBtn.mbClose, TArray<string>(VarArrayOf(['Button-1','Button-2','Button-3','Button-4','Button-5'])))

【讨论】:

  • 由于参数是一个开放的数组参数,你甚至不需要声明一个动态数组变量。
  • MessageDlg('Where do you want to go today?', TMsgDlgType.mtCustom, mbOKCancel, 0, TMsgDlgBtn.mbOK, ['Redmond', 'New York'])
猜你喜欢
  • 2016-05-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-01-17
  • 2010-12-21
  • 1970-01-01
  • 2014-02-09
相关资源
最近更新 更多