码迷,mamicode.com
首页 > 其他好文 > 详细

Messagedlg

时间:2016-04-24 12:41:35      阅读:248      评论:0      收藏:0      [点我收藏+]

标签:

 
if MessageDlg(‘Welcome to my Delphi application. Exit now?‘, mtConfirmation,[mbYes, mbNo], 0) = mrYes then
  Close;

MessageDlg用法

对话框类型:
mtwarning——含有感叹号的警告对话框
mterror——含有红色叉符号的错误对话框
mtinformation——含有蓝色i符号的信息对话框
mtconfirmation——含有绿色问号的确认对话框
mtcustom——不含图标的一般对话框,对话框的标题是程序的名称

按钮组中的按钮:
mbYes——mrYes或6
mbNo——mrNo或7
mbOk——mrOk或1
mbCancel——mrCancel或2
mbHelp——help按钮
mbAbort——mrAbort或3
mbRetry——mrRetry或4
mbIgnore——mrIgnore或5
mbAll——mrAll或8
mbNoToAll——9
mbYesToAll——10

procedure TForm1.Button1Click(Sender: TObject);
var
  S:string;
begin
  if MessageDlg(‘提示框‘,mtInformation,[mbok,mbyes],0)=mryes then
  messagebeep(MB_ICONEXCLAMATION);
end;

MessageDlg()信息的汉化 
Delphi中的常量都放在consts.pas中,修改它可以达到汉化的目的.如: 
MessageDlg()显示的窗口标题及其中的 
按钮标题都是英文,虽然不影响使用,但在一个中文软件中总显得有些不协调. 
为此在consts.pas中查找以下内容: 
"SMsgDlgWarning" 
把

  SMsgDlgWarning = ‘Warning‘;
  SMsgDlgError = ‘Error‘;
  SMsgDlgInformation = ‘Information‘;
  SMsgDlgConfirm = ‘Confirm‘;
  SMsgDlgYes = ‘&Yes‘;
  SMsgDlgNo = ‘&No‘;
  SMsgDlgOK = ‘OK‘;
  SMsgDlgCancel = ‘Cancel‘;
  SMsgDlgHelp = ‘&Help‘;
  SMsgDlgHelpNone = ‘No help available‘;
  SMsgDlgHelpHelp = ‘Help‘;
  SMsgDlgAbort = ‘&Abort‘;
  SMsgDlgRetry = ‘&Retry‘;
  SMsgDlgIgnore = ‘&Ignore‘;
  SMsgDlgAll = ‘&All‘;
  SMsgDlgNoToAll = ‘N&o to All‘;
  SMsgDlgYesToAll = ‘Yes to &All‘;
  SMsgDlgClose = ‘&Close‘;

改成

  SMsgDlgWarning = ‘警告‘;
  SMsgDlgError = ‘错误‘;
  SMsgDlgInformation = ‘提示‘;
  SMsgDlgConfirm = ‘确认‘;
  SMsgDlgYes = ‘是(&Y)‘;
  SMsgDlgNo = ‘不(&N)‘;
  SMsgDlgOK = ‘确定‘;
  SMsgDlgCancel = ‘取消‘;
  SMsgDlgHelp = ‘帮助(&H)‘;
  SMsgDlgHelpNone = ‘没有该帮助信息‘;
  SMsgDlgHelpHelp = ‘帮助‘;
  SMsgDlgAbort = ‘放弃(&A)‘;
  SMsgDlgRetry = ‘重试(&R)‘;
  SMsgDlgIgnore = ‘忽略(&I)‘;
  SMsgDlgAll = ‘全部(&A)‘;
  SMsgDlgNoToAll = ‘全都不(&O)‘;
  SMsgDlgYesToAll = ‘全都是(&A)‘;
  SMsgDlgClose = ‘关闭(&C)‘;

然后重新编译Consts.pas,把Consts.dcu 
拷到delphi的lib子目录下,就一劳永逸啦!

Messagedlg

标签:

原文地址:http://www.cnblogs.com/Zory/p/5426643.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!