Delphi中Messagedlg用法

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

Close; 
end;

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;

TMsgDlgType
= (mtWarning, mtError, mtInformation, mtConfirmation, mtCustom);

TMsgDlgBtn
= (mbYes, mbNo, mbOK, mbCancel, mbAbort, mbRetry, mbIgnore,
mbAll, mbNoToAll, mbYesToAll, mbHelp);

const
mrNone
= 0;
mrOk
= idOk;
mrCancel
= idCancel;
mrAbort
= idAbort;
mrRetry
= idRetry;
mrIgnore
= idIgnore;
mrYes
= idYes;
mrNo
= idNo;
mrAll
= mrNo + 1;
mrNoToAll
= mrAll + 1;
mrYesToAll
= mrNoToAll + 1;



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';


改成

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)';

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

posted @ 2011-03-09 12:16  许明吉博客  阅读(30983)  评论(0编辑  收藏  举报