标签:
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子目录下,就一劳永逸啦!
标签:
原文地址:http://www.cnblogs.com/Zory/p/5426643.html